コード例 #1
0
        public void SetUp()
        {
            theSelfValidatingSource = new SelfValidatingClassRuleSource();

            theFieldRegistry = new FieldRulesRegistry(new IFieldValidationSource[0], new TypeDescriptorCache());
            theGraph = new ValidationGraph(theFieldRegistry, new IValidationSource[0]);
        }
コード例 #2
0
        public void SetUp()
        {
            theBehaviorGraph = BehaviorGraph.BuildFrom(r =>
            {
                r.Actions.IncludeType<RemoteRuleGraphEndpoint>();
                r.Features.Validation.Enable(true);
            });

            theValidationGraph = ValidationGraph.BasicGraph();
            theRuleGraph = new RemoteRuleGraph();
            theQuery = RemoteRuleQuery.Basic();

            theActivator = new RemoteRuleGraphActivator(theValidationGraph, theRuleGraph, theBehaviorGraph, theQuery, new TypeDescriptorCache());

            theActivator.Activate(new ActivationLog(), new PerfTimer());
        }
コード例 #3
0
ファイル: ValidationPlan.cs プロジェクト: zzekikaya/fubumvc
        public static ValidationPlan For(Type type, ValidationGraph graph)
        {
            var steps = new List <ValidationStep>();

            graph.Sources.Each(source =>
            {
                var rules = source.RulesFor(type);
                if (!rules.Any())
                {
                    return;
                }

                steps.Add(new ValidationStep(type, source.GetType(), rules));
            });

            return(new ValidationPlan(type, steps));
        }
コード例 #4
0
 void IValidationRegistration.Register(ValidationGraph graph)
 {
     _rules.Each(r => r.Register(graph.Fields));
     graph.RegisterSource(this);
 }
コード例 #5
0
 public void Register(ValidationGraph graph)
 {
     Configured = graph;
 }
コード例 #6
0
 public static IValidator BasicValidator()
 {
     return(new Validator(new TypeResolver(), ValidationGraph.BasicGraph(), new InMemoryServiceLocator()));
 }
コード例 #7
0
 public Validator(ITypeResolver typeResolver, ValidationGraph graph, IServiceLocator services)
 {
     _typeResolver = typeResolver;
     _graph        = graph;
     _services     = services;
 }
コード例 #8
0
        public void SetUp()
        {
            theModel = new ContactModel();
            theType = theModel.GetType();

            r1 = MockRepository.GenerateStub<IValidationRule>();
            r2 = MockRepository.GenerateStub<IValidationRule>();
            r3 = MockRepository.GenerateStub<IValidationRule>();

            theMatchingSource = ConfiguredValidationSource.For(type => type == theType, r1, r2);
            theOtherSource = ConfiguredValidationSource.For(type => type == typeof(int), r3);

            theGraph = ValidationGraph.BasicGraph();
            theGraph.RegisterSource(theMatchingSource);
            theGraph.RegisterSource(theOtherSource);

            theContext = ValidationContext.For(theModel);

            thePlan = ValidationPlan.For(theType, theGraph);
        }