public static ILogger GetFileLogger(string path) { var logger = StoreLogger.New(NaturalInMemoryStore.New().Polls()); logger.Store.GetPoll().SetBackgroundAction(LogicOf <IStore> .New((store) => { var dat = StoreSerializer.SerializeStore(store, ValueManagerChainOfResponsibility.NewDefault()); Debug.WriteLine(dat); dat.MakeStringable().Fileable().Filing(path).Write(); }), 100); return(logger); }
public StoreProtocolClientDecoration(IEndPointClient decorated, ValueManagerChainOfResponsibility valueManager = null) : base(decorated) { if (valueManager == null) { this.ValueManager = ValueManagerChainOfResponsibility.NewDefault(); } else { this.ValueManager = valueManager; } }
public GraphingTest() : base(LogicOf <Nothing> .New((x) => { //build an object up var id = "id".BuildAsId(); var guid = Guid.NewGuid(); var hasGuid = id.HasGUID(guid); var now = DateTime.Now; var hasDateCreated = hasGuid.HasDateCreated(now); var lastTouchedDate = DateTime.Now; var hasLastTouched = hasDateCreated.HasDateLastTouched(lastTouchedDate); var localMachineName = NetUtil.GetLocalMachineName(); var hasLM = hasLastTouched.HasLocalMachineName(); var ip = NetUtil.GetLocalIPAddresses().First(); var hasIP = hasLM.HasIP(ip); var hasRS = hasIP.HasRandomString("blah"); var hasV = hasRS.HasVersion("v"); //graph it var objState1 = hasV.GraphSerializeWithDefaults(); var readable = LengthEncoder.MakeReadable(objState1, "\t"); readable.WithEach(i => { Debug.WriteLine(i); }); var graph = Graph.Parse(objState1, ValueManagerChainOfResponsibility.NewDefault()); var readable2 = GraphingUtil.ConvertToXML(graph).ToString(); var obj2 = objState1.GraphDeserializeWithDefaults() as HasVersionDecoration; Condition.Requires(obj2.Version).IsEqualTo("v"); Condition.Requires(obj2.As <HasRandomStringDecoration>(true).RandomString).IsEqualTo("blah"); Condition.Requires(obj2.As <HasIPDecoration>(true).IPAddress.ToString()).IsEqualTo(ip.ToString()); Condition.Requires(obj2.As <HasMachineNameDecoration>(true).MachineName).IsEqualTo(localMachineName); Condition.Requires(obj2.As <HasDateLastTouchedDecoration>(true).DateLastTouched.ToString()).IsEqualTo(lastTouchedDate.ToUniversalTime().ToString()); Condition.Requires(obj2.As <HasDateCreatedDecoration>(true).DateCreated.ToString()).IsEqualTo(now.ToUniversalTime().ToString()); Condition.Requires(obj2.As <HasGUIDDecoration>(true).GUID).IsEqualTo(guid); Condition.Requires(obj2.Id.ToString()).IsEqualTo("id"); hasV.Version = "v2"; var objState2 = hasV.GraphSerializeWithDefaults(); var obj3 = objState2.GraphDeserializeWithDefaults() as HasVersionDecoration; Condition.Requires(obj3.Version).IsEqualTo("v2"); })) { }
public StoreProtocolHostDecoration(IEndPointHost decorated, LogicOf <Tuple <IStore, IStore> > storeProtocolLogic, ValueManagerChainOfResponsibility valueManager = null) : base(decorated) { Condition.Requires(storeProtocolLogic).IsNotNull(); this.StoreProtocolLogic = storeProtocolLogic; if (valueManager == null) { this.ValueManager = ValueManagerChainOfResponsibility.NewDefault(); } else { this.ValueManager = valueManager; } //replace the logic this.Logic = LogicOfTo <string, string> .New((request) => { return(this.HandleStoreProtocolRequest(request)); }); }
public static void RunTest(this ITestable testable) { Condition.Requires(testable).IsNotNull(); var tests = testable.GetTests(); var testStore = testable.GenerateTestInput(); IStore testResultsStore = NaturalInMemoryStore.New(); tests.HandleOperations(testStore, testResultsStore); var errors = tests.GetErrors(testResultsStore); if (errors != null && errors.Count > 0) { //output the stores testResultsStore.JoinStore(testStore); var dump = StoreSerializer.SerializeStore(testResultsStore, ValueManagerChainOfResponsibility.NewDefault()); Debug.WriteLine(dump); throw new InvalidOperationException("test failure"); } }
public static object GraphDeserializeWithDefaults(this string data) { return(GraphDeserialize(data, ValueManagerChainOfResponsibility.NewDefault())); }
public static string GraphSerializeWithDefaults(this object obj, Func <object, GraphPath, bool> skipFilter = null) { return(GraphSerialize(obj, ValueManagerChainOfResponsibility.NewDefault(), skipFilter)); }
public static Graph NewDefault() { Graph graph = new Graph(ValueManagerChainOfResponsibility.NewDefault()); return(graph); }