Esempio n. 1
0
        public static void FubuValidationWith(this Registry registry, IncludePackageAssemblies packageAssemblies, params Assembly[] assemblies)
        {
            registry.ForSingletonOf <ITypeDescriptorCache>().Use <TypeDescriptorCache>();
            registry.For <IValidator>().Use <Validator>();
            registry.For <IValidationSource>().Add <UniqueValidationSource>();
            registry.ForSingletonOf <IFieldRulesRegistry>().Add <FieldRulesRegistry>();
            registry.For <IValidationSource>().Add <FieldRuleSource>();
            registry.For <IValidationQuery>().Add <ValidationQuery>();

            var convention = new ValidationConvention();

            registry.Scan(x =>
            {
                assemblies.Each(x.Assembly);
                if (packageAssemblies == IncludePackageAssemblies.Yes)
                {
                    PackageRegistry.PackageAssemblies.Each(x.Assembly);
                }

                x.With(convention);
            });

            registry.Activate <IFieldRulesRegistry>("Applying explicit field validtion rules", fieldRules =>
            {
                convention.Registrations.Each(x => x.RegisterFieldRules(fieldRules));
            });
        }
Esempio n. 2
0
        public static void FubuValidationWith(this Registry registry, IncludePackageAssemblies packageAssemblies, params Assembly[] assemblies)
        {
            registry.ForSingletonOf<ITypeDescriptorCache>().Use<TypeDescriptorCache>();
            registry.For<IValidator>().Use<Validator>();
            registry.For<IValidationSource>().Add<UniqueValidationSource>();
            registry.ForSingletonOf<IFieldRulesRegistry>().Add<FieldRulesRegistry>();
            registry.For<IValidationSource>().Add<FieldRuleSource>();

            var convention = new ValidationConvention();
            registry.Scan(x =>
            {
                assemblies.Each(x.Assembly);
                if (packageAssemblies == IncludePackageAssemblies.Yes)
                {
                    PackageRegistry.PackageAssemblies.Each(x.Assembly);
                }

                x.With(convention);
            });

            registry.Activate<IFieldRulesRegistry>("Applying explicit field validtion rules", fieldRules =>
            {
                convention.Registrations.Each(x => x.RegisterFieldRules(fieldRules));
            });
        }