protected override void OnBefore(IInvocation invocation) { var validator = (IValidator)Activator.CreateInstance(_validatorType);//çalışma anında instance oluşturma var entityType = _validatorType.BaseType.GetGenericArguments()[0]; var entities = invocation.Arguments.Where(t => t.GetType() == entityType); foreach (var entity in entities) { ValidationTool.Validate(validator, entity); } }
public override void OnBefore(IInvocation invocation) { var validator = (IValidator)Activator.CreateInstance(Type); var entityType = Type.BaseType.GetGenericArguments()[0]; var entities = invocation.Arguments.Where(e => e.GetType() == entityType); foreach (var entity in entities) { ValidationTool.Validate(validator, entity); } }
public override void OnBefore(IInvocation invocation) { var actions = new[] { "Insert", "Update" }; var action = invocation.Method.Name.Replace("Async", ""); if (_auto && !actions.ToList().Contains(action)) { return; } var validator = (IValidator)Activator.CreateInstance(_validatorType); if (_validatorType.BaseType == null) { return; } var entityType = _validatorType.BaseType.GetGenericArguments()[0]; var entities = invocation.Arguments.Where(t => t.GetType() == entityType); foreach (var entity in entities) { ValidationTool.Validate(validator, entity); } }