コード例 #1
0
        public ValidationInterceptorTest()
        {
            var validatorProvider = new DefaultValidatorProvider();

            validatorProvider.AddValidatorFromAssembly(typeof(ValidationInterceptorTest).Assembly);

            _interceptor = new ValidationInterceptor(validatorProvider);
        }
コード例 #2
0
        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]);
            }
        }
コード例 #3
0
 internal SessionValidator(ValidationInterceptor validationInterceptor)
 {
     _validationInterceptor = validationInterceptor;
 }
コード例 #4
0
 internal SessionValidator(ValidationInterceptor validationInterceptor)
 {
     _validationInterceptor = validationInterceptor;
 }