Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ ValidateMethodParameter()

string System.ComponentModel.DataAnnotations.CustomValidationAttribute.ValidateMethodParameter ( )
inlineprivate

Definition at line 110 of file CustomValidationAttribute.cs.

111 {
112 if (string.IsNullOrEmpty(Method))
113 {
115 }
116 MethodInfo methodInfo = ValidatorType.GetMethods(BindingFlags.Static | BindingFlags.Public).SingleOrDefault((MethodInfo m) => string.Equals(m.Name, Method, StringComparison.Ordinal));
117 if (methodInfo == null)
118 {
120 }
121 if (!typeof(ValidationResult).IsAssignableFrom(methodInfo.ReturnType))
122 {
124 }
125 ParameterInfo[] parameters = methodInfo.GetParameters();
126 if (parameters.Length == 0 || parameters[0].ParameterType.IsByRef)
127 {
129 }
130 _isSingleArgumentMethod = parameters.Length == 1;
131 if (!_isSingleArgumentMethod && (parameters.Length != 2 || parameters[1].ParameterType != typeof(ValidationContext)))
132 {
134 }
135 _methodInfo = methodInfo;
136 _firstParameterType = parameters[0].ParameterType;
137 return null;
138 }
override bool Equals([NotNullWhen(true)] object? obj)
Definition Attribute.cs:691
ParameterInfo[] GetParameters()
static string CustomValidationAttribute_Method_Required
Definition SR.cs:32
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string CustomValidationAttribute_Method_Must_Return_ValidationResult
Definition SR.cs:28
static string CustomValidationAttribute_Method_Not_Found
Definition SR.cs:30
static string CustomValidationAttribute_Method_Signature
Definition SR.cs:34
Definition SR.cs:7
MethodInfo[] GetMethods()
Definition Type.cs:788
bool IsByRef
Definition Type.cs:73

References System.ComponentModel.DataAnnotations.CustomValidationAttribute._firstParameterType, System.ComponentModel.DataAnnotations.CustomValidationAttribute._isSingleArgumentMethod, System.ComponentModel.DataAnnotations.CustomValidationAttribute._methodInfo, System.SR.CustomValidationAttribute_Method_Must_Return_ValidationResult, System.SR.CustomValidationAttribute_Method_Not_Found, System.SR.CustomValidationAttribute_Method_Required, System.SR.CustomValidationAttribute_Method_Signature, System.Attribute.Equals(), System.SR.Format(), System.Type.GetMethods(), System.Reflection.MethodBase.GetParameters(), System.Type.IsByRef, System.ComponentModel.DataAnnotations.CustomValidationAttribute.Method, System.Reflection.MemberInfo.Name, System.Reflection.ParameterInfo.ParameterType, System.Reflection.MethodInfo.ReturnType, and System.ComponentModel.DataAnnotations.CustomValidationAttribute.ValidatorType.

Referenced by System.ComponentModel.DataAnnotations.CustomValidationAttribute.CheckAttributeWellFormed().