Exemple #1
0
            public static ValidationResult?ValidateEditableString2(TestClass1 obj, string?value)
            {
                var list = new List <ValidationResult>();

                Validator.TryValidateProperty(
                    value,
                    new ValidationContext(obj, null, null)
                {
                    MemberName = NameOfEditableString2
                }, list);

                obj.ValidateEditableString2(value, list);

                if (list.Count > 0)
                {
                    foreach (var result in list)
                    {
                        foreach (var name in result.MemberNames)
                        {
                            obj.AddError(name, result.ErrorMessage);
                        }
                    }

                    return(list[0]);
                }

                obj.RemoveError(NameOfEditableString2);

                return(ValidationResult.Success);
            }
            public static bool IsValid(TestClass1 obj)
            {
                try
                {
                    obj._isValidCounter++;

                    var flag0 = ValidationResult.Success == ValidateEditableLong1(obj, obj.EditableLong1);
                    var flag1 = ValidationResult.Success == ValidateEditableInt1(obj, obj.EditableInt1);

                    return(flag0 || flag1);
                }
                finally
                {
                    obj._isValidCounter--;
                }
            }
Exemple #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="obj"></param>
 /// <returns></returns>
 public static ValidationResult?ValidateEditableInt1(TestClass1 obj)
 {
     return(ValidationResult.Success);
 }