Exemplo n.º 1
0
        public void Deserialize(IEnumerable <IValue> values)
        {
            var valueItems = new List <object>();
            var visitor    = new ObjectVisitor(value =>
            {
                valueItems.Add(value);
            });

            foreach (var value in values)
            {
                value.Visit(visitor);
            }

            // Now. Because toml-test is stupid, arrays of tables are different to arrays
            // of anything else...
            var first = values.FirstOrDefault();

            if (first != null && first.Type == TomlValueType.Table)
            {
                this.callback(valueItems);
            }
            else
            {
                this.callback(new Dictionary <string, object>()
                {
                    { "type", "array" },
                    { "value", valueItems },
                });
            }
        }
Exemplo n.º 2
0
        public void Deserialize(IEnumerable<IValue> values)
        {
            var valueItems = new List<object>();
            var visitor = new ObjectVisitor(value =>
            {
                valueItems.Add(value);
            });

            foreach (var value in values)
            {
                value.Visit(visitor);
            }

            // Now. Because toml-test is stupid, arrays of tables are different to arrays
            // of anything else...
            var first = values.FirstOrDefault();
            if (first != null && first.Type == TomlValueType.Table)
            {
                this.callback(valueItems);
            }
            else
            {
                this.callback(new Dictionary<string, object>()
                {
                    { "type", "array" },
                    { "value", valueItems },
                });
            }
        }
Exemplo n.º 3
0
        public void Deserialize(IValue rootTable)
        {
            object retVal = null;
            var visitor = new ObjectVisitor(value =>
            {
                retVal = value;
            });
            rootTable.Visit(visitor);

            this.Value = JsonConvert.SerializeObject(retVal, Formatting.Indented);
        }
Exemplo n.º 4
0
        public void Deserialize(IValue rootTable)
        {
            object retVal  = null;
            var    visitor = new ObjectVisitor(value =>
            {
                retVal = value;
            });

            rootTable.Visit(visitor);

            this.Value = JsonConvert.SerializeObject(retVal, Formatting.Indented);
        }
Exemplo n.º 5
0
        public void Deserialize(IDictionary <string, IValue> values)
        {
            var objects = new Dictionary <string, object>();

            foreach (var kvp in values)
            {
                var visitor = new ObjectVisitor(value =>
                {
                    objects.Add(kvp.Key, value);
                });
                kvp.Value.Visit(visitor);
            }

            this.callback(objects);
        }
Exemplo n.º 6
0
        public void Deserialize(IDictionary<string, IValue> values)
        {
            var objects = new Dictionary<string, object>();

            foreach (var kvp in values)
            {
                var visitor = new ObjectVisitor(value =>
                {
                    objects.Add(kvp.Key, value);
                });
                kvp.Value.Visit(visitor);
            }

            this.callback(objects);
        }