예제 #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();
                    }
                });
            }
        }
예제 #2
0
        public void WriteReport(IValueReport report)
        {
            _dictionary.Keys.ToList().Each(key =>
            {
                var value = _dictionary[key];

                if (value is IDictionary <string, object> )
                {
                    report.StartChild(key);
                    var child = Child(key);
                    child.WriteReport(report);
                    report.EndChild();
                }
                else if (value is IEnumerable <IDictionary <string, object> > )
                {
                    var children = value.As <IEnumerable <IDictionary <string, object> > >()
                                   .Select(x => new SettingsData(x))
                                   .ToList();


                    for (int i = 0; i < children.Count; i++)
                    {
                        report.StartChild(key, i);
                        children[i].WriteReport(report);
                        report.EndChild();
                    }
                }
                else
                {
                    report.Value(key, value);
                }
            });
        }
        public void nested_child()
        {
            theSource.Child("Child").As <SettingsData>().Set("A", 1);

            using (theMocks.Ordered())
            {
                theReport.StartChild("Child");

                theReport.Value("A", 1);

                theReport.EndChild();
            }

            theMocks.ReplayAll();

            theSource.WriteReport(theReport);

            theMocks.VerifyAll();
        }
        public void WriteReport(IValueReport report)
        {
            _dictionary.Keys.ToList().Each(key =>
            {
                var value = _dictionary[key];

                if (value is IDictionary<string, object>)
                {
                    report.StartChild(key);
                    var child = Child(key);
                    child.WriteReport(report);
                    report.EndChild();
                }
                else if (value is IEnumerable<IDictionary<string, object>>)
                {
                    var children = value.As<IEnumerable<IDictionary<string, object>>>()
                        .Select(x => new SettingsData(x))
                        .ToList();


                    for (int i = 0; i < children.Count; i++)
                    {
                        report.StartChild(key, i);
                        children[i].WriteReport(report);
                        report.EndChild();
                    }
                }
                else
                {
                    report.Value(key, value);
                }

            });
        }