public IElementDescriptor GetElementDescriptor() { var descr = new ElementDescriptor(this, "Property", null, (attr) => { attr("Name", () => Name); attr("Value", () => Value); }); return descr; }
public IElementDescriptor GetElementDescriptor() { var descr = new ElementDescriptor(this, "Property", null, (attr) => { attr("Name", () => Name); attr("Value", () => Value); }); return(descr); }
public static IElementDescriptor CreateFor(object o) { IElementDescriptorAdaptable adaptable = o as IElementDescriptorAdaptable; if (adaptable != null) { return(adaptable.GetElementDescriptor()); } else { var type = o.GetType(); var name = type.Name; ElementDescriptor ed = null; ed = new ElementDescriptor(o, name, () => { var children = new List <object>(); var properties = type.GetProperties().Where(p => IsEnumerable(p.PropertyType)); foreach (var prop in properties) { var e = prop.GetValue(o, null) as IEnumerable; if (e != null) { foreach (var item in e) { children.Add(item); } } } return(children); }, (attr) => { var properties = type.GetProperties().Where(p => !IsEnumerable(p.PropertyType)); foreach (var prop in properties) { var _prop = prop; //for lambda reference attr(_prop.Name, () => "" + _prop.GetValue(o, null)); } }); return(ed); } }
public IElementDescriptor GetElementDescriptor() { var descriptor = new ElementDescriptor(this, "Vertex", () => ((IEnumerable<object>)Properties.Values) .Concat(Children) .Concat(new [] { new Foo { Name = "A foo"}, new Foo { Name = "Another foo"} }), (attr) => { attr("ID", () => ID); attr("Name", () => Name); }); return descriptor; }
public IElementDescriptor GetElementDescriptor() { var descriptor = new ElementDescriptor(this, "Vertex", () => ((IEnumerable <object>)Properties.Values) .Concat(Children) .Concat(new [] { new Foo { Name = "A foo" }, new Foo { Name = "Another foo" } }), (attr) => { attr("ID", () => ID); attr("Name", () => Name); }); return(descriptor); }
public static IElementDescriptor CreateFor(object o) { IElementDescriptorAdaptable adaptable = o as IElementDescriptorAdaptable; if (adaptable != null) { return adaptable.GetElementDescriptor(); } else { var type = o.GetType(); var name = type.Name; ElementDescriptor ed = null; ed = new ElementDescriptor(o, name, () => { var children = new List<object>(); var properties = type.GetProperties().Where(p => IsEnumerable(p.PropertyType)); foreach (var prop in properties) { var e = prop.GetValue(o, null) as IEnumerable; if (e != null) { foreach (var item in e) { children.Add(item); } } } return children; }, (attr) => { var properties = type.GetProperties().Where(p=>!IsEnumerable(p.PropertyType)); foreach (var prop in properties) { var _prop = prop; //for lambda reference attr(_prop.Name, () => ""+_prop.GetValue(o, null)); } }); return ed; } }