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

◆ IsValid() [2/2]

override? ValidationResult System.ComponentModel.DataAnnotations.CompareAttribute.IsValid ( object? value,
ValidationContext validationContext )
inlineprotectedvirtual

Reimplemented from System.ComponentModel.DataAnnotations.ValidationAttribute.

Definition at line 30 of file CompareAttribute.cs.

31 {
32 PropertyInfo runtimeProperty = validationContext.ObjectType.GetRuntimeProperty(OtherProperty);
33 if (runtimeProperty == null)
34 {
36 }
37 if (runtimeProperty.GetIndexParameters().Length != 0)
38 {
40 }
41 object value2 = runtimeProperty.GetValue(validationContext.ObjectInstance, null);
42 if (!object.Equals(value, value2))
43 {
44 if (OtherPropertyDisplayName == null)
45 {
47 }
48 string[] memberNames = ((validationContext.MemberName == null) ? null : new string[1] { validationContext.MemberName });
49 return new ValidationResult(FormatErrorMessage(validationContext.DisplayName), memberNames);
50 }
51 return null;
52 }
override bool Equals([NotNullWhen(true)] object? obj)
Definition Attribute.cs:691
static string Common_PropertyNotFound
Definition SR.cs:20
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string CompareAttribute_UnknownProperty
Definition SR.cs:24
Definition SR.cs:7

References System.SR.Common_PropertyNotFound, System.SR.CompareAttribute_UnknownProperty, System.Attribute.Equals(), System.SR.Format(), System.ComponentModel.DataAnnotations.CompareAttribute.FormatErrorMessage(), System.ComponentModel.DataAnnotations.CompareAttribute.GetDisplayNameForProperty(), System.ComponentModel.DataAnnotations.CompareAttribute.OtherProperty, System.ComponentModel.DataAnnotations.CompareAttribute.OtherPropertyDisplayName, and System.value.