public void TestGetPropertyDescriptor1M() { var provider = new DataAnnotationsTypeDescriptionProvider(TypeDescriptor.GetProvider(typeof (TestEntity))); var start = DateTime.Now; for(int i = 0; i < 1000000; i++) { provider.GetTypeDescriptor(typeof (TestEntity), null); } var end = DateTime.Now; Console.WriteLine(end - start); }
private bool IsBindable(Type modelType, string propertyName) { if(TypeDescriptionProvider == null) TypeDescriptionProvider = new DataAnnotationsTypeDescriptionProvider(TypeDescriptor.GetProvider(modelType)); var descriptor = TypeDescriptionProvider.GetTypeDescriptor(modelType); var properties = descriptor.GetProperties(); var attributes = properties[propertyName].Attributes.OfType<DenyClientModificationAttribute>(); //if(attributes.Count > 0) there is a DenyClientModificationAttribute so not bindable. return !(attributes.Count() > 0); }