Exemplo n.º 1
0
        private static object TraverseObject(object obj, Field[] fields, ObjectTreeNode objectTreeNode)
        {
            if (fields.IsNullOrEmpty())
            {
                return(obj);
            }

            var result = new Dictionary <string, object>();

            foreach (var field in fields)
            {
                var property = objectTreeNode.FindProperty(field.Name);
                if (property == null)
                {
                    continue;
                }

                var value = property.GetValue(obj);

                var subfields = field.Fields;
                result.Add(property.ResponseName, Traverse(value, subfields, property.Tree));
            }

            return(result);
        }
Exemplo n.º 2
0
 private static Field[] SelectObject(ObjectTreeNode obj)
 {
     return(obj
            .Properties
            .Select(p => new Field
     {
         Name = p.ResponseName,
         Fields = SelectFields(p.Tree)
     }).ToArray());
 }