예제 #1
0
 public IElementDescriptor GetElementDescriptor()
 {
     var descr = new ElementDescriptor(this, "Property", null,
         (attr) =>
         {
             attr("Name", () => Name);
             attr("Value", () => Value);
         });
     return descr;
 }
예제 #2
0
        public IElementDescriptor GetElementDescriptor()
        {
            var descr = new ElementDescriptor(this, "Property", null,
                                              (attr) =>
            {
                attr("Name", () => Name);
                attr("Value", () => Value);
            });

            return(descr);
        }
예제 #3
0
        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);
            }
        }
예제 #4
0
        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;
        }
예제 #5
0
        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);
        }
예제 #6
0
        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;
            }
        }