Ejemplo n.º 1
0
        public ICustomCommand Create(params dynamic[] args)
        {
            ICustomReceiver  aReceiver  = args.OfType <ICustomReceiver>().FirstOrDefault();
            ICustomValidator aValidator = args.OfType <ICustomValidator>().FirstOrDefault();

            return(new CustomCommand(aReceiver, aValidator));
        }
Ejemplo n.º 2
0
        public RegistrationModelValidator()
        {
            context         = ContextProvider.GetApplicationContext();
            customValidator = new CustomValidator <RegistrationModel>();

            SetDefaultRules();
        }
Ejemplo n.º 3
0
        public void TestCustomValidator_Create()
        {
            IFactory <ICustomValidator> fact = new CustomValidatorFactory();

            Assert.IsNotNull(fact);

            ICustomValidator validator = fact.Create();

            Assert.IsNotNull(validator);
        }
Ejemplo n.º 4
0
        public void SetCommand(ICustomCommand aCommand, ICustomValidator aValidator = null)
        {
            Validator = (aValidator == null) ? new CustomValidator() : aValidator;

            if (aCommand == null)
            {
                throw new ArgumentNullException("Command is null");
            }
            Command = aCommand;
        }
Ejemplo n.º 5
0
        public void AttachTo(ICustomReceiver aReceiver, ICustomValidator aValidator = null)
        {
            Validator = (aValidator == null) ? new CustomValidator() : aValidator;

            if (!Validator.IsValidArgument(aReceiver))
            {
                throw new ArgumentNullException("Command receiver cannot be null");
            }
            Receiver = aReceiver;
        }
Ejemplo n.º 6
0
        public void SetCommand(ICustomCommand aCommand, ICustomValidator aValidator = null)
        {
            Validator = (aValidator == null) ? new CustomValidator() : aValidator;

            if (aCommand == null)
            {
                throw new ArgumentNullException("Command is null");
            }
            Command = aCommand;
        }
        public void AttachTo(ICustomReceiver aReceiver, ICustomValidator aValidator = null)
        {
            Validator = (aValidator == null) ? new CustomValidator() : aValidator;

            if (!Validator.IsValidArgument(aReceiver))
            {
                throw new ArgumentNullException("Command receiver cannot be null");
            }
            Receiver = aReceiver;
        }
        public void AttachCommand(Action <object> anAction, ICustomValidator aValidator = null)
        {
            Validator = (aValidator == null) ? new CustomValidator() : aValidator;

            if (anAction == null)
            {
                throw new ArgumentNullException("Command action is null");
            }

            CommandAction = anAction;
        }
        public void AttachCommand(Action<object> anAction, ICustomValidator aValidator = null)
        {
            Validator = (aValidator == null) ? new CustomValidator() : aValidator;

            if (anAction == null)
            {
                throw new ArgumentNullException("Command action is null");
            }

            CommandAction = anAction;
        }
        public ICustomSender Create(params dynamic[] args)
        {
            ICustomCommand   aCommand   = args.OfType <ICustomCommand>().FirstOrDefault();
            ICustomValidator aValidator = args.OfType <ICustomValidator>().FirstOrDefault();

            if (aCommand == null)
            {
                return(new CustomSender());
            }
            else
            {
                var retObj = new CustomSender();
                retObj.SetCommand(aCommand, aValidator);
                return(retObj);
            }
        }
Ejemplo n.º 11
0
        public ICustomReceiver Create(params dynamic[] args)
        {
            Action <object>  anAction   = args.OfType <Action <object> >().FirstOrDefault();
            ICustomValidator aValidator = args.OfType <ICustomValidator>().FirstOrDefault();

            if (anAction == null)
            {
                return(new CustomReceiver());
            }
            else
            {
                var retObj = new CustomReceiver();
                retObj.AttachCommand(anAction, aValidator);
                return(retObj);
            }
        }
Ejemplo n.º 12
0
 public void RemoveCommand()
 {
     Validator = null;
     Command = null;
 }
 public CustumerService(ICustumerRepository repo, IMapper mapper, ICustomValidator <InsertCustumer.Request> validator)
 {
     _repo      = repo;
     _mapper    = mapper;
     _validator = validator;
 }
Ejemplo n.º 14
0
 protected StoreService(IDataContext <T> context, ICustomValidator <T> validator)
 {
     this.Context   = context ?? throw new ArgumentNullException(nameof(context));
     this.Validator = validator ?? throw new ArgumentNullException(nameof(validator));
 }
 /// <summary>
 /// Use this attribute to validate to model on the body of all incoming requests to this function using a custom validator
 /// </summary>
 /// <param name="type">The type of the model to be validated</param>
 /// <param name="resultParameterName">Paramer name to inject validation results. Must be of type <code>ICollection<ValidationResult></code></param>
 /// <param name="customValidatorFactory">A method that returns an instance of the custom validator to use</param>
 public CustomValidateAttribute(Type type, string resultParameterName, Func <ICustomValidator> customValidatorFactory)
 {
     this.type            = type;
     this.paramName       = resultParameterName;
     this.customValidator = customValidatorFactory();
 }
Ejemplo n.º 16
0
 public void Dettach()
 {
     Receiver = null;
     Validator = null;
 }
Ejemplo n.º 17
0
        public QuizModelValidator()
        {
            customValidator = new CustomValidator <QuizModel>();

            SetDefaultRules();
        }
 /// <summary>
 /// Use this attribute to validate to model on the body of all incoming requests to this function using a custom validator
 /// </summary>
 /// <param name="type">The type of the model to be validated</param>
 /// <param name="resultParameterName">Paramer name to inject validation results. Must be of type <code>ICollection<ValidationResult></code>/param>
 /// <param name="customValidatorType">Type of the custom validator to use</param>
 public CustomValidateAttribute(Type type, string resultParameterName, Type customValidatorType)
 {
     this.type            = type;
     this.paramName       = resultParameterName;
     this.customValidator = Activator.CreateInstance(customValidatorType) as ICustomValidator;
 }
Ejemplo n.º 19
0
        public NewTestModelValidator()
        {
            customValidator = new CustomValidator <NewTestModel>();

            SetDefaultRules();
        }
 public void DettachCommand()
 {
     Validator = null;
     CommandAction = null;
 }
Ejemplo n.º 21
0
        public LoginModelValidator()
        {
            customValidator = new CustomValidator <LoginModel>();

            SetDefaultRules();
        }
Ejemplo n.º 22
0
 protected ModelValidator(ICustomValidator <TModel> customValidator)
 {
     CascadeMode      = DefaultCascadeMode;
     _customValidator = customValidator;
 }
Ejemplo n.º 23
0
 protected virtual string CustomValidate(RowValidationContext context, Field field, ICustomValidator validator)
 {
     return(validator.Validate(context));
 }
Ejemplo n.º 24
0
 public bool IsValid(ICustomValidator validator, List<IndicatorValue> values)
 {
     bool isValid = true;
     foreach (DynamicContainer cnt in controlList)
     {
         if (cnt.Control == null)
             continue;
         string message = validator.Valid(cnt.Indicator, values);
         indicatorErrors.SetError(cnt.Control, message);
         if (!string.IsNullOrEmpty(message))
             isValid = false;
     }
     return isValid;
 }