Exemplo n.º 1
0
 public IElementDescriptor GetElementDescriptor()
 {
     var descr = new ElementDescriptor(this, "Property", null,
         (attr) =>
         {
             attr("Name", () => Name);
             attr("Value", () => Value);
         });
     return descr;
 }
Exemplo n.º 2
0
        public IElementDescriptor GetElementDescriptor()
        {
            var descr = new ElementDescriptor(this, "Property", null,
                                              (attr) =>
            {
                attr("Name", () => Name);
                attr("Value", () => Value);
            });

            return(descr);
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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;
        }
Exemplo n.º 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);
        }
Exemplo n.º 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;
            }
        }