Exemple #1
0
        private bool WriteSyntaxObjectNode(SyntaxObjectNode Node)
        {
            EnterChunk();
            JsonString_.Push('{');
            JsonString_.Push('\n');

            var Keys = Node.GetKeys();

            for (var Index = 0; Index < Keys.Length; ++Index)
            {
                var Child = Node.GetValue(Keys[Index]);
                WriteChunkTab();
                JsonString_.Push('"');
                JsonString_.PushString(Keys[Index]);
                JsonString_.Push('"');
                JsonString_.PushString(" : ");
                WriteSyntaxNode(Child);
                if (Index != Keys.Length - 1)
                {
                    JsonString_.Push(',');
                }
                JsonString_.Push('\n');
            }

            LeaveChunk();
            WriteChunkTab();
            JsonString_.Push('}');
            return(true);
        }
Exemple #2
0
        private static JsonObject ParseJsonObjectFromNode(SyntaxObjectNode Node)
        {
            var Keys    = Node.GetKeys();
            var JsonObj = new JsonObject();

            foreach (var Key in Keys)
            {
                var Value = ParseJsonValueFromNode(Node.GetValue(Key));
                JsonObj.SetValue(Key, Value);
            }

            return(JsonObj);
        }
Exemple #3
0
        private static object ParseObjectFromNode(Type ObjType, SyntaxObjectNode Node)
        {
            var Obj  = Activator.CreateInstance(ObjType);
            var Keys = Node.GetKeys();

            foreach (var Key in Keys)
            {
                var Info = ObjType.GetField(Key, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
                if (Info == null)
                {
                    continue;
                }

                var ChildValue = ParseValueFromNode(Info.FieldType, Node.GetValue(Key));
                Info.SetValue(Obj, ChildValue);
            }

            return(Obj);
        }