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

            return(rv);
        }
예제 #2
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);
        }
예제 #3
0
파일: Tests.cs 프로젝트: Piirtaa/Decoratid
        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");
        }))
        {
        }
예제 #4
0
파일: Graph.cs 프로젝트: Piirtaa/Decoratid
 /// <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;
 }