internal IEnumerable <ValidationAttribute> GetPropertyValidationAttributes(ValidationContext validationContext) { ValidationAttributeStore.EnsureValidationContext(validationContext); ValidationAttributeStore.TypeStoreItem typeStoreItem = this.GetTypeStoreItem(validationContext.ObjectType); ValidationAttributeStore.PropertyStoreItem propertyStoreItem = typeStoreItem.GetPropertyStoreItem(validationContext.MemberName); return(propertyStoreItem.ValidationAttributes); }
internal Type GetPropertyType(ValidationContext validationContext) { ValidationAttributeStore.EnsureValidationContext(validationContext); ValidationAttributeStore.TypeStoreItem typeStoreItem = this.GetTypeStoreItem(validationContext.ObjectType); ValidationAttributeStore.PropertyStoreItem propertyStoreItem = typeStoreItem.GetPropertyStoreItem(validationContext.MemberName); return(propertyStoreItem.PropertyType); }
private Dictionary <string, ValidationAttributeStore.PropertyStoreItem> CreatePropertyStoreItems() { Dictionary <string, ValidationAttributeStore.PropertyStoreItem> strs = new Dictionary <string, ValidationAttributeStore.PropertyStoreItem>(); PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(this.m_type); foreach (PropertyDescriptor property in properties) { ValidationAttributeStore.PropertyStoreItem propertyStoreItem = new ValidationAttributeStore.PropertyStoreItem(property.PropertyType, ValidationAttributeStore.TypeStoreItem.GetExplicitAttributes(property).Cast <Attribute>()); strs[property.Name] = propertyStoreItem; } return(strs); }
internal bool TryGetPropertyStoreItem(string propertyName, out ValidationAttributeStore.PropertyStoreItem item) { if (!string.IsNullOrEmpty(propertyName)) { if (this.m_propertyStoreItems == null) { lock (this.m_syncRoot) { if (this.m_propertyStoreItems == null) { this.m_propertyStoreItems = this.CreatePropertyStoreItems(); } } } return(this.m_propertyStoreItems.TryGetValue(propertyName, out item)); } throw new ArgumentNullException("propertyName"); }