Exemple #1
0
        public void WriteReport(IValueReport report)
        {
            foreach (var pair in _jObject)
            {
                var key = pair.Key;

                pair.IfIs <JValue>(value => report.Value(key, value.Value <string>()));

                pair.IfIs <JObject>(jo =>
                {
                    report.StartChild(key);

                    var child = new JObjectValues(jo);
                    child.WriteReport(report);

                    report.EndChild();
                });

                pair.IfIs <JArray>(ja =>
                {
                    int i = 0;
                    foreach (JObject jo in ja.OfType <JObject>())
                    {
                        report.StartChild(key, i);

                        var child = new JObjectValues(jo);
                        child.WriteReport(report);

                        report.EndChild();
                    }
                });
            }
        }
Exemple #2
0
        public T ReadFromJson(string json)
        {
            var values = new JObjectValues(json);

            return((T)_resolver.BindModel(typeof(T), values).Value);
        }