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)); }
public void GetItemType_OfNonEnumerableType_ReturnsNull() { var actual = TypeService.GetItemType(typeof(Object)); Assert.IsNull(actual); }
public void GetItemType_OfCustumEnumerableImplementation_ReturnsItemType() { var actual = TypeService.GetItemType(typeof(CustomEnumerable <object, int>)); Assert.AreSame(typeof(int), actual); }
public void GetItemType_OfHashSet_ReturnsItemType() { var actual = TypeService.GetItemType(typeof(HashSet <int>)); Assert.AreSame(typeof(int), actual); }