using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ProofOfConcept;
namespace DocumentLanguage
{ public class Dh : IModules, IActionable, ISelector
{ private DhSemanticModel semanticModel;
private Guid lastModule;
private Dh()
{ semanticModel = new DhSemanticModel();
}
public static IModules Using
{ get
{ return new Dh();
}
}
public ISelector CallForService
{ get
{ this.lastModule = WellKnownModules.CallForServiceModuleId;
return this;
}
}
public ISelector CaseFolder
{ get
{ this.lastModule = WellKnownModules.CaseFolderModuleId;
return this;
}
}
public ISelector CaseReport
{ get
{ this.lastModule = WellKnownModules.CaseReportModuleId;
return this;
}
}
public ISelector AnimalControl
{ get
{ this.lastModule = WellKnownModules.AnimalControlModuleId;
return this;
}
}
public IActionable Perform(Action<dynamic> action)
{ semanticModel.RegisterPerformAction(action);
return this;
}
public IActionable Id(params Guid[] numbers)
{ semanticModel.RegisterDocumentIdentities(this.lastModule, numbers);
return this;
}
public IActionable Where(params Func<Fieldx, Comparison>[] condition)
{ var fx = new Fieldx();
semanticModel.RegisterConditions(
condition.ToList().ConvertAll(f => f(fx)));
return this;
}
public void Save()
{ semanticModel.RegisterCommand("Save"); }
public void Seal()
{ semanticModel.RegisterCommand("Seal"); }
public void Archive()
{ semanticModel.RegisterCommand("Archive"); }
public void Delete()
{ semanticModel.RegisterCommand("Delete"); }
public IModules And
{ get
{ return this;
}
}
public IActionable DocumentExtension(string extensionName)
{ semanticModel.RegisterDocumentExtension(this.lastModule, extensionName);
return this;
}
}
public interface IModules
{ ISelector CallForService { get; } ISelector CaseReport { get; } ISelector CaseFolder { get; } ISelector AnimalControl { get; } }
public interface ISelector
{ IActionable Id(params Guid[] numbers);
IActionable Where(params Func<Fieldx, Comparison>[] condition);
IActionable DocumentExtension(string extensionName);
}
public interface IActionable
{ IActionable Perform(Action<dynamic> action);
void Save();
void Seal();
void Delete();
void Archive();
IModules And { get; } }
public class Fieldx
{ public Field this[string fieldName]
{ get
{ return new Field(fieldName);
}
}
}
public class Field
{ private string name;
public Field(string name)
{ this.name = name;
}
public Comparison LessThan (DateTime date)
{ return new Comparison();
}
public NegativeField Not
{ get
{ return new NegativeField(this);
}
}
}
public class NegativeField
{ private Field field;
public NegativeField(Field field)
{ this.field = field;
}
public Comparison EqualTo(object value)
{ return new Comparison();
}
}
public class Comparison
{ internal Comparison()
{ }
}
}