public static PropertyDescriptorCollection GetPropertiesOf(Type type)
        {
            Type itemType = TypeService.GetItemType(collectionType: type);

            if (itemType != null)
            {
                type = itemType;
            }

            IVMDescriptor childDescriptor = ClassDescriptorAttribute
                                            .GetClassDescriptorOf(type);

            if (childDescriptor != null)
            {
                var browsableDescriptors = childDescriptor
                                           .GetPropertyDescriptors()
                                           .OfType <ViewModelPropertyDescriptor>()
                                           .Select(actual => new BrowsablePropertyDescriptor(actual))
                                           .ToArray();

                return(new PropertyDescriptorCollection(browsableDescriptors));
            }

            return(TypeDescriptor.GetProperties(type));
        }
Exemplo n.º 2
0
        public void GetItemType_OfNonEnumerableType_ReturnsNull()
        {
            var actual = TypeService.GetItemType(typeof(Object));

            Assert.IsNull(actual);
        }
Exemplo n.º 3
0
        public void GetItemType_OfCustumEnumerableImplementation_ReturnsItemType()
        {
            var actual = TypeService.GetItemType(typeof(CustomEnumerable <object, int>));

            Assert.AreSame(typeof(int), actual);
        }
Exemplo n.º 4
0
        public void GetItemType_OfHashSet_ReturnsItemType()
        {
            var actual = TypeService.GetItemType(typeof(HashSet <int>));

            Assert.AreSame(typeof(int), actual);
        }