public static Rules Custom(this Rules rules, ValidationDelegate validation) { var customRule = new CustomRule(validation); rules.Add(customRule); return(rules); }
public void RemoveValidationDelegate(ValidationDelegate func) { if (_validationDelegates.Contains(func)) { _validationDelegates.Remove(func); } }
/// <summary> /// Constructor. /// </summary> /// <param name="propertyName">The property to which this rule applies.</param> /// <param name="callback">A method that performs the validation.</param> public ValidationRule(string propertyName, ValidationDelegate callback) { Platform.CheckForNullReference(propertyName, "propertyName"); Platform.CheckForNullReference(callback, "callback"); _propertyName = propertyName; _callback = callback; }
public ValidateWithAttribute(ValidationDelegate DelegateFunction) { if (DelegateFunction == null) { throw new ArgumentNullException("DelegateFunction"); } this.InvokeDelegate = DelegateFunction; }
public ValidateWithAttribute(string MethodName) { this.InvokeDelegate = (object ValidationResult, MemberInfo member) => { var mi = ValidationResult.GetType().GetMethod(MethodName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); if (mi == null) { throw new NullReferenceException(String.Format("Could not find method '{0}' to validate member '{1}' with", MethodName, member.Name)); } ValidationResult result = (ValidationResult)mi.Invoke(ValidationResult, new object[] { ValidationResult, member }); return(result); }; }
private static void ValidateSection(ValidationDelegate Validation, Type TypeToValidate) { object o = Activator.CreateInstance(TypeToValidate); System.Reflection.FieldInfo[] Fields = o.GetType().GetFields(); //Validate file paths string Value = null; string Name = null; foreach (System.Reflection.FieldInfo Field in Fields) { Value = (string)Field.GetValue(o); Name = Field.Name; Validation(Value, Name); } }
/// <summary> /// Sets the delegate to be called when the field receives input. /// This delegate validates the input text. /// NOTE: This will unset any previously assigned validation delegate. /// </summary> /// <param name="del">The delegate to be called.</param> public void SetValidationDelegate(ValidationDelegate del) { validationDelegate = del; }
/// <summary> /// Adds a delegate to be called when the field receives input. /// This delegate validates the input text. /// </summary> /// <param name="del">The delegate to be called.</param> public void AddValidationDelegate(ValidationDelegate del) { validationDelegate += del; }
public ValidationRule(ValidationDelegate <t> handler, string ruleName, string description) { Handler = handler; RuleName = ruleName; Description = description; }
public ValidatingCondition(ValidationDelegate validate, LocalizedString description, bool abortValidationIfFailed) { this.validate = validate; this.description = description; this.abortValidationIfFailed = abortValidationIfFailed; }
public DelegateConstraint(ValidationDelegate validator) { this.validator = validator; }
public CustomRule(ValidationDelegate validation) { _validation = validation; }
/// <summary> /// The fully specified constructor /// </summary> /// <param name="operation">The Operation this implements</param> /// <param name="operationDelegate">The Operation Delegate</param> /// <param name="validationDelegate">The Validation Delegate</param> /// <param name="analyzer">The Analyzer Context</param> /// <param name="customOperation">The CustomOperation to use if operation is Custom</param> public OatOperation(Operation operation, OperationDelegate operationDelegate, ValidationDelegate validationDelegate, Analyzer analyzer, string?customOperation = null) : this(operation, analyzer) { OperationDelegate = operationDelegate; ValidationDelegate = validationDelegate; CustomOperation = customOperation; }
private async Task <IActionResult> Validation_EmailConfirmation_ModelState(ClaimsPrincipal User, ModelStateDictionary ModelState, ValidationDelegate handler) { return(await TryCatchLog(async() => { var user = await userManager.GetUserAsync(User); if (user.EmailConfirmed) { if (ModelState.IsValid) { return handler(user); } string errorMessage = ""; foreach (ModelStateEntry modelState in ModelState.Values) { foreach (ModelError error in modelState.Errors) { errorMessage += error.ErrorMessage + " "; } } return Conflict(errorMessage); } return Conflict("Unconfirmed Email"); })); }
private async Task <IActionResult> Validation_UserExistance_EmailConfirmation_ModelState(ClaimsPrincipal User, string userId, ModelStateDictionary ModelState, ValidationDelegate handler) { return(await Validation_EmailConfirmation_ModelState(User, ModelState, async (user) => { if ((await userManager.FindByIdAsync(userId)) == null) { return Conflict("User Not found"); } return await handler(user); })); }
private async Task <IActionResult> Validation_EmailConfirmation_ModelState(ClaimsPrincipal User, ModelStateDictionary ModelState, ValidationDelegate handler) { return(await Validation_ModelState_wLog(ModelState, async() => { var user = await userManager.GetUserAsync(User); if (!user.EmailConfirmed) { return Conflict("Unconfirmed Email"); } return await handler(user); })); }
public ValidatedItemRule(string Validation, string Description, ValidationDelegate <IValidatedItem> handler) { RuleName = Validation; this.Description = Description; ValidationHandler = handler; }
/// <summary> /// Removes a delegate previously added or set by AddValidationDelegate() /// or SetValidationDelegate(). /// </summary> /// <param name="del">The delegate to be removed.</param> public void RemoveValidationDelegate(ValidationDelegate del) { validationDelegate -= del; }
public static void SetValidate(TextBox textbox, ValidationDelegate value) { textbox.SetValue(ValidateProperty, value); }
public void AddValidationDelegate(ValidationDelegate func) { _validationDelegates.Add(func); }