private void UpdateFlyweight(MemberInfo memberInfo, Type targetType) { this.memberInfo = memberInfo; this.targetType = targetType; this.ignoreNullsAttribute = ValidationReflectionHelper.ExtractValidationAttribute <IgnoreNullsAttribute>(memberInfo, this.ruleset); this.validatorCompositionAttribute = ValidationReflectionHelper.ExtractValidationAttribute <ValidatorCompositionAttribute>(memberInfo, this.ruleset); }
IEnumerable <IValidatedElement> IValidatedType.GetValidatedProperties() { MetadataValidatedElement iteratorVariable0 = new MetadataValidatedElement(this.Ruleset); foreach (PropertyInfo iteratorVariable1 in this.TargetType.GetProperties(BindingFlags.Public | BindingFlags.Instance)) { if (ValidationReflectionHelper.IsValidProperty(iteratorVariable1)) { iteratorVariable0.UpdateFlyweight(iteratorVariable1); yield return(iteratorVariable0); } } }
public static MethodInfo GetMethod(Type type, string methodName, bool throwIfInvalid) { if (string.IsNullOrEmpty(methodName)) { throw new ArgumentNullException("methodName"); } MethodInfo method = type.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public, null, Type.EmptyTypes, null); if (!ValidationReflectionHelper.IsValidMethod(method)) { if (throwIfInvalid) { throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.ExceptionInvalidMethod, methodName, type.FullName)); } return(null); } return(method); }
public static FieldInfo GetField(Type type, string fieldName, bool throwIfInvalid) { if (string.IsNullOrEmpty(fieldName)) { throw new ArgumentNullException("fieldName"); } FieldInfo field = type.GetField(fieldName, BindingFlags.Instance | BindingFlags.Public); if (!ValidationReflectionHelper.IsValidField(field)) { if (throwIfInvalid) { throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.ExceptionInvalidField, fieldName, type.FullName)); } return(null); } return(field); }
public static PropertyInfo GetProperty(Type type, string propertyName, bool throwIfInvalid) { if (string.IsNullOrEmpty(propertyName)) { throw new ArgumentNullException("propertyName"); } PropertyInfo property = type.GetProperty(propertyName, BindingFlags.Instance | BindingFlags.Public); if (!ValidationReflectionHelper.IsValidProperty(property)) { if (throwIfInvalid) { throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.ExceptionInvalidProperty, propertyName, type.FullName)); } return(null); } return(property); }
IEnumerable <IValidatedElement> IValidatedType.GetValidatedProperties() { MetadataValidatedElement flyweight = new MetadataValidatedElement(base.Ruleset); try { PropertyInfo[] properties = base.TargetType.GetProperties(BindingFlags.Instance | BindingFlags.Public); foreach (PropertyInfo propertyInfo in properties) { if (ValidationReflectionHelper.IsValidProperty(propertyInfo)) { flyweight.UpdateFlyweight(propertyInfo); yield return((IValidatedElement)flyweight); } } } finally { } }
IEnumerable <IValidatedElement> IValidatedType.GetValidatedMethods() { MetadataValidatedElement flyweight = new MetadataValidatedElement(base.Ruleset); try { MethodInfo[] methods = base.TargetType.GetMethods(BindingFlags.Instance | BindingFlags.Public); foreach (MethodInfo methodInfo in methods) { methodInfo.GetParameters(); if (ValidationReflectionHelper.IsValidMethod(methodInfo)) { flyweight.UpdateFlyweight(methodInfo); yield return((IValidatedElement)flyweight); } } } finally { } }
IEnumerable <IValidatedElement> IValidatedType.GetValidatedProperties() { MetadataValidatedElement metadataValidatedElement = new MetadataValidatedElement(base.Ruleset); try { PropertyInfo[] properties = base.TargetType.GetProperties(BindingFlags.Instance | BindingFlags.Public); for (int i = 0; i < properties.Length; i++) { PropertyInfo propertyInfo = properties[i]; if (ValidationReflectionHelper.IsValidProperty(propertyInfo)) { metadataValidatedElement.UpdateFlyweight(propertyInfo); yield return(metadataValidatedElement); } } } finally { } yield break; }
IEnumerable <IValidatedElement> IValidatedType.GetValidatedMethods() { MetadataValidatedElement metadataValidatedElement = new MetadataValidatedElement(base.Ruleset); try { MethodInfo[] methods = base.TargetType.GetMethods(BindingFlags.Instance | BindingFlags.Public); for (int i = 0; i < methods.Length; i++) { MethodInfo methodInfo = methods[i]; methodInfo.GetParameters(); if (ValidationReflectionHelper.IsValidMethod(methodInfo)) { metadataValidatedElement.UpdateFlyweight(methodInfo); yield return(metadataValidatedElement); } } } finally { } yield break; }
public void UpdateFlyweight(ParameterInfo parameterInfo) { this.parameterInfo = parameterInfo; this.ignoreNullsAttribute = ValidationReflectionHelper.ExtractValidationAttribute <IgnoreNullsAttribute>(parameterInfo, string.Empty); this.validatorCompositionAttribute = ValidationReflectionHelper.ExtractValidationAttribute <ValidatorCompositionAttribute>(parameterInfo, string.Empty); }