public ValidationInterceptorTest() { var validatorProvider = new DefaultValidatorProvider(); validatorProvider.AddValidatorFromAssembly(typeof(ValidationInterceptorTest).Assembly); _interceptor = new ValidationInterceptor(validatorProvider); }
internal static IInterceptor[] GetInterceptors(Type type) { EntityClass entity = _entites.Value[type.FullName]; if (entity.IsNotNull()) { //TO DO Cache List <IInterceptor> interceptors = new List <IInterceptor>(); interceptors.Add(SecurityInterceptor.GetInstance()); interceptors.Add(ModificationInterceptor.GetInstance()); if (entity.Validators.Count(v => v.RealTimeValidation) > 0 || entity.Properties.SelectMany(p => p.Validators.Where(v => v.RealTimeValidation), (p, v) => v).Count() > 0) { interceptors.Add(ValidationInterceptor.GetInstance()); } entity.Properties.Where(p => p.ReletedEntity.IsNotNull()).ToList(). ForEach((p) => { if (p.ReletedEntity.Related == Releted.List) { interceptors.Add(CollectionInterceptorDispatcher.GetInstance(p.ReletedEntity.RelatedEntity.EntityType)); } else { interceptors.Add(EntityInterceptorDispatcher.GetInstance(p.ReletedEntity.RelatedEntity.EntityType)); } }); entity.Attributes.Where(a => a.IsTypeOf <Interceptor>()).Select(a => a.CastToType <Interceptor>()).ToList(). ForEach((i) => { interceptors.Add(i); }); return(interceptors.ToArray()); } else { return(new IInterceptor[0]); } }
internal SessionValidator(ValidationInterceptor validationInterceptor) { _validationInterceptor = validationInterceptor; }