Ejemplo n.º 1
0
        public static object GraphDeserialize(this string data, ValueManagerChainOfResponsibility managerSet)
        {
            var graph = Graph.Parse(data, managerSet);
            var rv    = graph.RootNode.NodeValue;

            return(rv);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// serializes using Graph then Encodes
 /// </summary>
 /// <param name="obj"></param>
 /// <param name="managerSet"></param>
 /// <param name="encodingStrategy"></param>
 /// <returns></returns>
 private static string SerializeItem(object obj, ValueManagerChainOfResponsibility managerSet)
 {
     var graph = Graph.Build(obj, managerSet);
     var text = graph.GetValue(); //serialize using graph
     //var valueEncodedData = ValueEncoder.LengthEncode(encodedData);//value encode
     return text;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// converts the provided object into a graph
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="valueManagers">if null, the Default managers are used</param>
        /// <returns></returns>
        public static Graph Build(object obj, ValueManagerChainOfResponsibility managerSet, Func <object, GraphPath, bool> skipFilter = null)
        {
            Graph graph = new Graph(managerSet);

            graph.BuildGraph(obj, skipFilter);
            return(graph);
        }
Ejemplo n.º 4
0
        public static string GraphSerialize(this object obj, ValueManagerChainOfResponsibility managerSet, Func <object, GraphPath, bool> skipFilter = null)
        {
            var graph = Graph.Build(obj, managerSet, skipFilter);
            var rv    = graph.GetValue();

            return(rv);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// hydrates the graph from a string
        /// </summary>
        /// <param name="text"></param>
        /// <param name="valueManagers">if null, the Default managers are used</param>
        /// <returns></returns>
        public static Graph Parse(string text, ValueManagerChainOfResponsibility managerSet)
        {
            Graph graph = new Graph(managerSet);

            graph.Parse(text);
            return(graph);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// serializes using Graph then Encodes
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="managerSet"></param>
        /// <param name="encodingStrategy"></param>
        /// <returns></returns>
        private static string SerializeItem(object obj, ValueManagerChainOfResponsibility managerSet)
        {
            var graph = Graph.Build(obj, managerSet);
            var text  = graph.GetValue(); //serialize using graph

            //var valueEncodedData = ValueEncoder.LengthEncode(encodedData);//value encode
            return(text);
        }
Ejemplo n.º 7
0
 /// <summary>
 /// deserialization complement to SerializeItem
 /// </summary>
 /// <param name="text"></param>
 /// <param name="managerSet"></param>
 /// <param name="decodingStrategy"></param>
 /// <returns></returns>
 private static object DeserializeItem(string text, ValueManagerChainOfResponsibility managerSet)
 {
     //do the reverse of serialize
     //var valueDecodedData = ValueEncoder.LengthDecode(text); //value decode
     var graph = Graph.Parse(text, managerSet); //parse graph
     var item = graph.RootNode.NodeValue;
     return item;
 }  
Ejemplo n.º 8
0
        /// <summary>
        /// deserialization complement to SerializeItem
        /// </summary>
        /// <param name="text"></param>
        /// <param name="managerSet"></param>
        /// <param name="decodingStrategy"></param>
        /// <returns></returns>
        private static object DeserializeItem(string text, ValueManagerChainOfResponsibility managerSet)
        {
            //do the reverse of serialize
            //var valueDecodedData = ValueEncoder.LengthDecode(text); //value decode
            var graph = Graph.Parse(text, managerSet); //parse graph
            var item  = graph.RootNode.NodeValue;

            return(item);
        }
 public StoreProtocolClientDecoration(IEndPointClient decorated, ValueManagerChainOfResponsibility valueManager = null)
     : base(decorated)
 {
     if (valueManager == null)
     {
         this.ValueManager = ValueManagerChainOfResponsibility.NewDefault();
     }
     else
     {
         this.ValueManager = valueManager;
     }
 }
        public OperationProtocolHostDecoration(IEndPointHost decorated, ValueManagerChainOfResponsibility valueManager = null)
            : base(decorated.StoreProtocoling(null, valueManager))
        {
            this.OperationManager = OperationManager.New();

            //replace the store protocol logic
            this.As<StoreProtocolHostDecoration>(true).HasStoreProtocolLogic(
                LogicOf<Tuple<IStore, IStore>>.New((uow) =>
                {
                    this.OperationManager.HandleOperations(uow.Item1, uow.Item2);
                }));
        }
Ejemplo n.º 11
0
        public OperationProtocolHostDecoration(IEndPointHost decorated, ValueManagerChainOfResponsibility valueManager = null)
            : base(decorated.StoreProtocoling(null, valueManager))
        {
            this.OperationManager = OperationManager.New();

            //replace the store protocol logic
            this.As <StoreProtocolHostDecoration>(true).HasStoreProtocolLogic(
                LogicOf <Tuple <IStore, IStore> > .New((uow) =>
            {
                this.OperationManager.HandleOperations(uow.Item1, uow.Item2);
            }));
        }
 public StoreProtocolClientDecoration(IEndPointClient decorated, ValueManagerChainOfResponsibility valueManager = null)
     : base(decorated)
 {
     if (valueManager == null)
     {
         this.ValueManager = ValueManagerChainOfResponsibility.NewDefault();
     }
     else
     {
         this.ValueManager = valueManager;
     }
 }
Ejemplo n.º 13
0
        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);
        }
Ejemplo n.º 14
0
        public static IStore DeserializeStore(string data, ValueManagerChainOfResponsibility managerSet)
        {
            if (string.IsNullOrEmpty(data))
                return null;

            var list = LengthEncoder.LengthDecodeList(data);
            var store = NaturalInMemoryStore.New();
            list.WithEach(each =>
            {
                var item = DeserializeItem(each, managerSet);
                IHasId obj = item as IHasId;
                store.SaveItem(obj);
            });
            return store;
        }
Ejemplo n.º 15
0
        public static string SerializeStore(IGetAllableStore store, ValueManagerChainOfResponsibility managerSet)
        {
            if (store == null)
                return null;

            var all = store.GetAll();
            List<string> lines = new List<string>();
            all.WithEach(each =>
            {
                var line = SerializeItem(each, managerSet);
                lines.Add(line);
            });

            var raw= LengthEncoder.LengthEncodeList(lines.ToArray());
            return raw;
        }
Ejemplo n.º 16
0
        public void Parse(string text)
        {
            Condition.Requires(text).IsNotNullOrEmpty();
            var arr = LengthEncoder.LengthDecodeList(text);

            Condition.Requires(arr).HasLength(2);
            var storeText   = arr[1];
            var managerText = arr[0];

            var set = ValueManagerChainOfResponsibility.New();

            set.Parse(managerText);
            this.ChainOfResponsibility = set;
            var store = NodeStoreUtil.HydrateNodeStore(storeText);

            this.ReconstituteFromNodeStore(store);
        }
Ejemplo n.º 17
0
        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");
        }))
        {
        }
Ejemplo n.º 18
0
        public static IStore DeserializeStore(string data, ValueManagerChainOfResponsibility managerSet)
        {
            if (string.IsNullOrEmpty(data))
            {
                return(null);
            }

            var list  = LengthEncoder.LengthDecodeList(data);
            var store = NaturalInMemoryStore.New();

            list.WithEach(each =>
            {
                var item   = DeserializeItem(each, managerSet);
                IHasId obj = item as IHasId;
                store.SaveItem(obj);
            });
            return(store);
        }
        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 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);
            });
        }
Ejemplo n.º 21
0
        public static string SerializeStore(IGetAllableStore store, ValueManagerChainOfResponsibility managerSet)
        {
            if (store == null)
            {
                return(null);
            }

            var           all   = store.GetAll();
            List <string> lines = new List <string>();

            all.WithEach(each =>
            {
                var line = SerializeItem(each, managerSet);
                lines.Add(line);
            });

            var raw = LengthEncoder.LengthEncodeList(lines.ToArray());

            return(raw);
        }
Ejemplo n.º 22
0
        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 StoreProtocolHostDecoration New(IEndPointHost decorated, LogicOf<Tuple<IStore, IStore>> storeProtocolLogic, ValueManagerChainOfResponsibility valueManager = null)
 {
     return new StoreProtocolHostDecoration(decorated, storeProtocolLogic, valueManager);
 }
 public static StoreProtocolHostDecoration StoreProtocoling(this IEndPointHost decorated, LogicOf<Tuple<IStore, IStore>> storeProtocolLogic, ValueManagerChainOfResponsibility valueManager = null)
 {
     var rv = new StoreProtocolHostDecoration(decorated, storeProtocolLogic, valueManager);
     return rv;
 }
Ejemplo n.º 25
0
 public static Graph New(ValueManagerChainOfResponsibility managerSet)
 {
     Graph graph = new Graph(managerSet);
     return graph;
 }
Ejemplo n.º 26
0
 private Graph(ValueManagerChainOfResponsibility chainOfResponsibility)
 {
     Condition.Requires(chainOfResponsibility).IsNotNull();
     this.ChainOfResponsibility = chainOfResponsibility;
 }
 public static StoreProtocolClientDecoration New(IEndPointClient decorated, ValueManagerChainOfResponsibility valueManager = null)
 {
     return(new StoreProtocolClientDecoration(decorated, valueManager));
 }
        public static StoreProtocolHostDecoration StoreProtocoling(this IEndPointHost decorated, LogicOf <Tuple <IStore, IStore> > storeProtocolLogic, ValueManagerChainOfResponsibility valueManager = null)
        {
            var rv = new StoreProtocolHostDecoration(decorated, storeProtocolLogic, valueManager);

            return(rv);
        }
Ejemplo n.º 29
0
 public static object GraphDeserializeWithDefaults(this string data)
 {
     return(GraphDeserialize(data, ValueManagerChainOfResponsibility.NewDefault()));
 }
 public static OperationProtocolClientDecoration New(IEndPointClient decorated, ValueManagerChainOfResponsibility valueManager = null)
 {
     return new OperationProtocolClientDecoration(decorated, valueManager);
 }
 public OperationProtocolClientDecoration(IEndPointClient decorated, ValueManagerChainOfResponsibility valueManager = null)
     : base(decorated.StoreProtocoling(valueManager))
 {
     this.RequestStore = NaturalInMemoryStore.New();
 }
Ejemplo n.º 32
0
 /// <summary>
 /// hydrates the graph from a string
 /// </summary>
 /// <param name="text"></param>
 /// <param name="valueManagers">if null, the Default managers are used</param>
 /// <returns></returns>
 public static Graph Parse(string text, ValueManagerChainOfResponsibility managerSet)
 {
     Graph graph = new Graph(managerSet);
     graph.Parse(text);
     return graph;
 }
Ejemplo n.º 33
0
        public static OperationProtocolHostDecoration OperationProtocoling(this IEndPointHost decorated, ValueManagerChainOfResponsibility valueManager = null)
        {
            var rv = new OperationProtocolHostDecoration(decorated, valueManager);

            return(rv);
        }
Ejemplo n.º 34
0
 public static OperationProtocolHostDecoration New(IEndPointHost decorated, ValueManagerChainOfResponsibility valueManager = null)
 {
     return(new OperationProtocolHostDecoration(decorated, valueManager));
 }
Ejemplo n.º 35
0
 public static string GraphSerialize(this object obj, ValueManagerChainOfResponsibility managerSet, Func<object, GraphPath, bool> skipFilter = null)
 {
     var graph = Graph.Build(obj, managerSet, skipFilter);
     var rv = graph.GetValue();
     return rv;
 }
Ejemplo n.º 36
0
 public static object GraphDeserialize(this string data, ValueManagerChainOfResponsibility managerSet)
 {
     var graph = Graph.Parse(data, managerSet);
     var rv = graph.RootNode.NodeValue;
     return rv;
 }
 public static StoreProtocolHostDecoration New(IEndPointHost decorated, LogicOf <Tuple <IStore, IStore> > storeProtocolLogic, ValueManagerChainOfResponsibility valueManager = null)
 {
     return(new StoreProtocolHostDecoration(decorated, storeProtocolLogic, valueManager));
 }
Ejemplo n.º 38
0
 public static string GraphSerializeWithDefaults(this object obj, Func <object, GraphPath, bool> skipFilter = null)
 {
     return(GraphSerialize(obj, ValueManagerChainOfResponsibility.NewDefault(), skipFilter));
 }
 public static OperationProtocolClientDecoration OperationProtocoling(this IEndPointClient decorated, ValueManagerChainOfResponsibility valueManager = null)
 {
     var rv = new OperationProtocolClientDecoration(decorated, valueManager);
     return rv;
 }
Ejemplo n.º 40
0
 private Graph(ValueManagerChainOfResponsibility chainOfResponsibility)
 {
     Condition.Requires(chainOfResponsibility).IsNotNull();
     this.ChainOfResponsibility = chainOfResponsibility;
 }
Ejemplo n.º 41
0
 /// <summary>
 /// converts the provided object into a graph
 /// </summary>
 /// <param name="obj"></param>
 /// <param name="valueManagers">if null, the Default managers are used</param>
 /// <returns></returns>
 public static Graph Build(object obj, ValueManagerChainOfResponsibility managerSet, Func<object, GraphPath, bool> skipFilter = null)
 {
     Graph graph = new Graph(managerSet);
     graph.BuildGraph(obj, skipFilter);
     return graph;
 }
        public static StoreProtocolClientDecoration StoreProtocoling(this IEndPointClient decorated, ValueManagerChainOfResponsibility valueManager = null)
        {
            var rv = new StoreProtocolClientDecoration(decorated, valueManager);

            return(rv);
        }
Ejemplo n.º 43
0
        public static Graph NewDefault()
        {
            Graph graph = new Graph(ValueManagerChainOfResponsibility.NewDefault());

            return(graph);
        }
Ejemplo n.º 44
0
 public OperationProtocolClientDecoration(IEndPointClient decorated, ValueManagerChainOfResponsibility valueManager = null)
     : base(decorated.StoreProtocoling(valueManager))
 {
     this.RequestStore = NaturalInMemoryStore.New();
 }
Ejemplo n.º 45
0
        public static Graph New(ValueManagerChainOfResponsibility managerSet)
        {
            Graph graph = new Graph(managerSet);

            return(graph);
        }