Esempio n. 1
0
        public void Initialize(RepositoryExtensionFactory.ExtensionEvents events, IConfiguration config)
        {
            events.AddtoValidateEntity(e =>
            {
                if (e.Entity is IValidate)
                {
                    IValidate model = e.Entity as IValidate;
                    e.Result        = model.ValidateModel(model);
                }
                else
                {
                    AttributedValidatorFactory validatorFactory = new AttributedValidatorFactory();

                    var validator = validatorFactory.GetValidator(e.Entity.GetType());
                    ValidationResult validationResults = validator.Validate(e.Entity);

                    IList <IValidationError> errors = new List <IValidationError>();


                    foreach (var error in validationResults.Errors)
                    {
                        errors.Add(new GenericValidationError {
                            PropertyName = error.PropertyName, ValidationError = error.ErrorMessage
                        });
                    }
                    IValidationResult ErrorResult = new GenericValidationResult {
                        IsValid = validationResults.IsValid, Errors = errors
                    };
                    e.Result = ErrorResult;
                }
            });
        }
Esempio n. 2
0
        public void Initialize(RepositoryExtensionFactory.ExtensionEvents events, IConfiguration config)
        {
            events.AddtoActionStarting((e) => {
                Debug.WriteLine("[Action Starting] [LOGGED] " + e.Entity.ToString() + " " + e.Action.ToString());
            });

            events.AddtoActionStared((e) => {
                Debug.WriteLine("[Action Completing] [LOGGED] " + e.Entity.ToString() + " " + e.Action.ToString());
            });


            //  events.CallEntityProcessed
        }
Esempio n. 3
0
 public void Initialize(RepositoryExtensionFactory.ExtensionEvents events, IConfiguration config)
 {
     events.AddtoActionStared(Validate);
 }
Esempio n. 4
0
 public void Initialize(RepositoryExtensionFactory.ExtensionEvents events)
 {
     events.AddtoActionStarting(Validate);
 }
Esempio n. 5
0
 public void Initialize(RepositoryExtensionFactory.ExtensionEvents events, NameValueCollection config)
 {
     events.AddtoActionStarting(Validate);
 }