コード例 #1
0
 public static void SelfRegister()
 {
     DataAnnotationsModelValidatorProvider
     .RegisterAdapter(
         typeof(LocalizedFkRequiredAttribute),
         typeof(FkAttributeAdapter));
 }
コード例 #2
0
        protected void Application_Start()
        {
            ModelBinders.Binders.DefaultBinder = new PerpetuumSoft.Knockout.KnockoutModelBinder();
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            //CultureInfo culture = new CultureInfo("ru-RU");
            //Thread.CurrentThread.CurrentCulture = culture;

            if (!Database.Exists("DefaultConnection"))
            {
                using (var context = new TaskManagerContext())
                {
                    try
                    {
                        ((IObjectContextAdapter)context).ObjectContext.CreateDatabase();
                    }
                    catch (Exception)
                    {
                    }
                }
            }

            if (!WebSecurity.Initialized)
            {
                WebSecurity.InitializeDatabaseConnection("DefaultConnection", "UserProfile", "UserId", "UserName", true);
            }
            DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(RequiredIfAttribute), typeof(RequiredIfValidator));
        }
コード例 #3
0
        protected void Application_Start()
        {
            try
            {
                Log.ErrorFormat("Aplicação Iniciada");

                GlobalConfiguration.Configure(WebApiConfig.Register);
                AreaRegistration.RegisterAllAreas();
                FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
                RouteConfig.RegisterRoutes(RouteTable.Routes);
                BundleConfig.RegisterBundles(BundleTable.Bundles);
                AutoMapperConfig.RegisterMappings();

                DataAnnotationsModelValidatorProvider.RegisterAdapter(
                    typeof(RequiredIfAttribute), typeof(RequiredIfValidator));
                DataAnnotationsModelValidatorProvider.RegisterAdapter(
                    typeof(AssertThatAttribute), typeof(AssertThatValidator));

                ViewEngines.Engines.Clear();
                ViewEngines.Engines.Add(new RazorViewEngine());
            }
            catch (Exception ex)
            {
                Log.ErrorFormat(ex.Message);
            }
        }
コード例 #4
0
ファイル: Global.asax.cs プロジェクト: navaei/NewsCMS
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            RegisterGlobalFilters(GlobalFilters.Filters);
            WebApiConfig.Register(GlobalConfiguration.Configuration);

            ViewEngines.Engines.Clear();
            ViewEngines.Engines.Add(new RazorViewEngine());

            DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(RequiredAttribute), typeof(RequiredMnAttribute));

            //ModelBinders.Binders.Add(typeof(DateTime), new PersianDateModelBinder());
            //ModelBinders.Binders.Add(typeof(DateTime?), new PersianDateModelBinder());

            Bootstrapper.Initialise();
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            //Mn.GetMedia.AppConfig.SoundcloudApiKeys = new List<string>() { ConfigurationManager.AppSettings["SoundcloudApiKey"] };
            //Mn.GetMedia.AppConfig.ApiKey = ConfigurationManager.AppSettings["TelegramGetMediaApiKey"];

            //ModelBinders.Binders.Add(typeof(DateTime), new DateTimeModelBinder("yyyy-mm-dd hh:mm"));
            //ModelBinders.Binders.Add(typeof(DateTime?), new DateTimeModelBinder("yyyy-mm-dd hh:mm"));

            //DisplayModeProvider.Instance.Modes.Insert(0, new DefaultDisplayMode("mobile")
            //{
            //    ContextCondition = (context => context.Request.IsMobile())
            //});
            CaptchaUtils.CaptchaManager.StorageProvider = new CookieStorageProvider();
            //Mn.NewsCms.Common.EventsLog.GeneralLogs.WriteLogInDB("Application Start at " + DateTime.Now.NowHour(), TypeOfLog.Start);
        }
コード例 #5
0
ファイル: Global.asax.cs プロジェクト: alFlash/mvc4-sample
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(CustomRequiredAttribute), typeof(CustomRequiredValidator));
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
 }
コード例 #6
0
ファイル: Global.asax.cs プロジェクト: Ruslan771/myoffice
        protected void Application_Start()
        {
            Thread.CurrentThread.CurrentCulture   = CultureInfo.CreateSpecificCulture("ru-RU");
            Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture("ru-RU");

            System.Data.Entity.Database.SetInitializer <Web.MyOffice.Data.DB>(new Web.MyOffice.Data.InitData());
            System.Data.Entity.Database.SetInitializer <ApplicationDbContext>(new ASE.EF.AutoMigrationInit <ApplicationDbContext>());

            GlobalConfiguration.Configure(WebApiConfig.Register);
            AreaRegistration.RegisterAllAreas();
            GlobalFilters.Filters.Add(new ASE.MVC.HistoryActionFilterAttribute());
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            ASE.MVC.BootstrapHelpers.Settings.LocalizeResourceManager = Web.MyOffice.Res.S.ResourceManager;

            ASE.MVC.LocalizedRequiredAttribute.ResourceManager  = Web.MyOffice.Res.S.ResourceManager;
            ASE.MVC.LocalizedDisplayAttribute.ResourceManager   = Web.MyOffice.Res.S.ResourceManager;
            ASE.MVC.LocalizedMinLengthAttribute.ResourceManager = Web.MyOffice.Res.S.ResourceManager;
            ASE.MVC.LocalizedCompareAttribute.ResourceManager   = Web.MyOffice.Res.S.ResourceManager;

            ASE.MVC.IdentinityExtension.ResourceManager = Web.MyOffice.Res.S.ResourceManager;

            ModelBinders.Binders.Add(typeof(decimal), new MvcDecimalModelBinder());
            ModelBinders.Binders.Add(typeof(decimal?), new MvcDecimalModelBinder());

            ModelBinders.Binders.Add(typeof(DateTime), new MvcDateTimeModelBinder());
            ModelBinders.Binders.Add(typeof(DateTime?), new MvcDateTimeModelBinder());

            //ViewEngines.Engines.Clear();
            ViewEngines.Engines.Add(new ViewEngineAdv());

            DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(LocalizedRequiredAttribute), typeof(RequiredAttributeAdapter));
        }
コード例 #7
0
ファイル: Global.asax.cs プロジェクト: md-prog/LL
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            ModelBinders.Binders.Add(typeof(DateTime?), new DateModelBinder());

            ClientDataTypeModelValidatorProvider.ResourceClassKey = "Messages";
            DefaultModelBinder.ResourceClassKey = "Messages";

            DataAnnotationsModelValidatorProvider.RegisterAdapter(
                typeof(RequiredAttribute),
                typeof(CustRequiredAttributeAdapter)
                );

            DataAnnotationsModelValidatorProvider.RegisterAdapter(
                typeof(RangeAttribute),
                typeof(CustRangeAttributeAdapter)
                );

            GlobalConfiguration.Configuration.EnsureInitialized();

            //JobManager.Initialize(new GamesRegistry());
        }
コード例 #8
0
 public static void SelfRegister()
 {
     DataAnnotationsModelValidatorProvider
     .RegisterAdapter(
         typeof(LocalizedDigitsOnlyAttribute),
         typeof(DigitsOnlyAttributeAdapter));
 }
コード例 #9
0
        void Application_Start(object sender, EventArgs e)
        {
            try
            {
                // Code that runs on application startup
                //WebApiConfig.Register(GlobalConfiguration.Configuration);
                BundleConfig.RegisterBundles(BundleTable.Bundles);
                AreaRegistration.RegisterAllAreas();
                FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
                GlobalConfiguration.Configure(WebApiConfig.Register);
                RouteConfig.RegisterRoutes(RouteTable.Routes);

                SetDbInitializer();
                ControllerBuilder.Current.SetControllerFactory(new StructureMapControllerFactory());
                // Microsoft.AspNet.SignalR.GlobalHost.DependencyResolver = SmObjectFactory.Container.GetInstance<Microsoft.AspNet.SignalR.IDependencyResolver>();
                // var captchaManager = (DefaultCaptchaManager)CaptchaUtils.CaptchaManager;
                DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(RequiredAttribute), typeof(CustomRequiredAttributeAdapter));
                DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(StringLengthAttribute), typeof(CustomStringLengthAttributeAdapter));
                DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(RangeAttribute), typeof(CustomRangeAttributeAdapter));


                DbInterception.Add(new SimpleInterceptor()); //for log sql command in Debug Window
            }
            catch
            {
                HttpRuntime.UnloadAppDomain(); // سبب ری استارت برنامه و آغاز مجدد آن با درخواست بعدی می‌شود
                throw;
            }
        }
コード例 #10
0
 public static void SelfRegister()
 {
     DataAnnotationsModelValidatorProvider
     .RegisterAdapter(
         typeof(LocalizedStringLengthAttribute),
         typeof(StringLengthAttributeAdapter));
 }
コード例 #11
0
        protected void Application_Start(object sender, EventArgs e)
        {
            log4net.Config.XmlConfigurator.Configure();

            _log.Debug("Application Started");

            AreaRegistration.RegisterAllAreas();

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);

            ModelBinders.Binders.Add(typeof(int[]), new CC.Web.Helpers.StringSplitModelBinder());

            DataAnnotationsModelValidatorProvider.RegisterAdapter(
                typeof(System.ComponentModel.DataAnnotations.DateFormatAttribute),
                typeof(System.Web.Mvc.RegularExpressionAttributeAdapter));
            DataAnnotationsModelValidatorProvider.RegisterAdapter(
                typeof(System.ComponentModel.DataAnnotations.ClientOnlyRegexAttribute),
                typeof(System.Web.Mvc.RegularExpressionAttributeAdapter));

#if !DEBUG
            try
            {
                Jobs.Schedule.StartSchedule();
            }
            catch (Exception ex)
            {
                _log.Fatal("Failed to start Quartz.net scheduler", ex);
            }
#endif
        }
コード例 #12
0
        protected void Application_Start()
        {
            System.Net.ServicePointManager.DefaultConnectionLimit = int.MaxValue;
            MvcHandler.DisableMvcResponseHeader = true;
            ViewEngines.Engines.Clear();
            ViewEngines.Engines.Add(new RazorViewEngine());
            DependencyRegistrar.Register("Web.Site");
            //DependencyRegistrar.Container
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(RangeBaseAttribute), typeof(RangeAttributeAdapter));
            DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(StringLengthBaseAttribute), typeof(StringLengthAttributeAdapter));
            DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(RequiredBaseAttribute), typeof(RequiredAttributeAdapter));
            DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(RequiredIfAttribute), typeof(RequiredAttributeAdapter));
            DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(RequiredToBeTrueAttribute), typeof(RequiredAttributeAdapter));
            ModelMetadataProviders.Current = new CachedDataAnnotationsModelMetadataProvider();
            System.Web.Mvc.ModelBinders.Binders.Add(typeof(DataTablesModel), new DataTablesModelBinder());
            //NotificationHub.InitializeChat();

            string publicKey = WebConfigurationManager.AppSettings["RecaptchaPublicKey"];
            string secretKey = WebConfigurationManager.AppSettings["RecaptchaPrivateKey"];

            ReCaptcha.Configure(publicKey, secretKey);

            //
            Localization.Init(WebConfigurationManager.AppSettings["Localization_EnabledLanguages"]);
        }
コード例 #13
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            ModelMetadataProviders.Current = new ModelMetadataProvider();

            DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(RequiredAttribute), typeof(RequiredAttributeAdapter));
            DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(IntegerAttribute), typeof(IntegerAttributeAdapter));
            DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(StringLengthAttribute), typeof(StringLengthAttributeAdapter));
            DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(RangeAttribute), typeof(RangeAttributeAdapter));
            DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(EmailAttribute), typeof(EmailAttributeAdapter));
            //DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(CompareAttribute), typeof(CompareAttributeAdapter));

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);

            var configuration = new Configuration.Configuration();

            configuration.ConfigureDatabase();

            var builder = configuration.GetContainerBuilder();

            builder.RegisterControllers(Assembly.GetExecutingAssembly());
            var container = builder.Build();

            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));

            SiteMapManager.SiteMaps.Register <XmlSiteMap>("Library.en-US", sitmap => sitmap.LoadFrom("~/Sitemaps/Library.en-US.sitemap"));
            SiteMapManager.SiteMaps.Register <XmlSiteMap>("Library.ru-RU", sitmap => sitmap.LoadFrom("~/Sitemaps/Library.ru-RU.sitemap"));
        }
コード例 #14
0
ファイル: AbpExWebMvcModule.cs プロジェクト: llenroc/AbpEx
        public override void PreInitialize()
        {
            Configuration.Localization.Sources.Add(
                new DictionaryBasedLocalizationSource(
                    AbpExWebMvcConsts.LocalizationSourceName,
                    new JsonEmbeddedFileLocalizationDictionaryProvider(
                        Assembly.GetExecutingAssembly(),
                        "Abp.Web.Mvc.Resources.Json"
                        )
                    )
                );

            //找出缺省的客户端数据验证类型
            var clientDataTypeValidator = ModelValidatorProviders.Providers.OfType <ClientDataTypeModelValidatorProvider>().FirstOrDefault();

            if (null != clientDataTypeValidator)
            {
                //如果有匹配删除该类型
                ModelValidatorProviders.Providers.Remove(clientDataTypeValidator);
            }

            //添加自定义的验证类型
            ModelValidatorProviders.Providers.Add(new FilterableClientDataTypeModelValidatorProvider());

            DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(LocalizedRequired), typeof(RequiredAttributeAdapter));
            DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(LocalizedStringLength), typeof(StringLengthAttributeAdapter));
            DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(LocalizedRegularExpression), typeof(RegularExpressionAttributeAdapter));
        }
コード例 #15
0
        protected void Application_Start()
        {
            GlobalConfiguration.Configure(WebApiConfig.Register);
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            DependencyConfig.Configure(new ContainerBuilder());

            DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(RequiredIfAttribute), typeof(RequiredIfValidator));
            DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(AssertThatAttribute), typeof(AssertThatValidator));

            // override standard error messages
            ClientDataTypeModelValidatorProvider.ResourceClassKey = "DefaultResources";
            DefaultModelBinder.ResourceClassKey = "DefaultResources";


            DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(RequiredAttribute), typeof(MyRequiredAttributeAdapter));

            // init log4net
            log4net.Config.XmlConfigurator.Configure();

            MvcHandler.DisableMvcResponseHeader = true;

            Store = new EmbeddableDocumentStore {
                ConnectionStringName = "RavenDB"
            };
            Store.Initialize();
        }
コード例 #16
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            log4net.Config.XmlConfigurator.Configure();
            MvcHandler.DisableMvcResponseHeader = true;

            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            EmailVerifier.RuntimeLicenseKey = "G016NUILAeGgF81JMB03zbbnuDKKCWJhQ9XYfo8HVhhJLA+Uk2l8Jqyqumxb9Pn78MEhaA==";

            DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(EmailAttribute), typeof(RegularExpressionAttributeAdapter));

            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

            Core.User.CurrentUserId = "NewWebsite";
            foreach (var t in  typeof(Area).Assembly.GetTypes().Where(t => t.IsSubclassOf(typeof(MetaBase))))
            {
                BaseEntity.MetaTypes.Add(t);
            }

            var config = new NHibernate.Cfg.Configuration();

            config.Configure();
            config.AddAssembly(typeof(NHibernateHelper).Assembly);
            config.AddAssembly(typeof(Page).Assembly);
            Global.SessionFactory = config.BuildSessionFactory();
        }
        public void RegisterAdapter()
        {
            var oldFactories = DataAnnotationsModelValidatorProvider.AttributeFactories;

            try
            {
                // Arrange
                DataAnnotationsModelValidatorProvider.AttributeFactories = new Dictionary <Type, DataAnnotationsModelValidationFactory>();

                // Act
                DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(MyValidationAttribute), typeof(MyValidationAttributeAdapter));

                // Assert
                var type = DataAnnotationsModelValidatorProvider.AttributeFactories.Keys.Single();
                Assert.Equal(typeof(MyValidationAttribute), type);

                var factory   = DataAnnotationsModelValidatorProvider.AttributeFactories.Values.Single();
                var metadata  = ModelMetadataProviders.Current.GetMetadataForType(() => null, typeof(object));
                var context   = new ControllerContext();
                var attribute = new MyValidationAttribute();
                var validator = factory(metadata, context, attribute);
                Assert.IsType <MyValidationAttributeAdapter>(validator);
            }
            finally
            {
                DataAnnotationsModelValidatorProvider.AttributeFactories = oldFactories;
            }
        }
コード例 #18
0
 private static void RegisterRedefinedExpressiveAttributes()
 {
     DataAnnotationsModelValidatorProvider.RegisterAdapter(
         typeof(LocalizedRequiredIfAttribute), typeof(LocalizedRequiredIfValidator));
     DataAnnotationsModelValidatorProvider.RegisterAdapter(
         typeof(LocalizedAssertThatAttribute), typeof(LocalizedAssertThatValidator));
 }
コード例 #19
0
        protected void Application_Start()
        {
#if DEBUG
            Database.SetInitializer <TaskDBContext>(new TaskDbContextInitializer());
            Database.SetInitializer <SchoolContext>(new SchoolInitializer());
            //  Database.SetInitializer<ImageContext>(new ImageInitializer());
            Database.SetInitializer <MovieContext>(new MovieInitializer());
#endif
            //ModelBinders.Binders.Add(typeof(Appointment), new ValidatingModelBinder());

            //ModelValidatorProviders.Providers.Clear();
            //ModelValidatorProviders.Providers.Add(new CustomValidationProvider());

            //HtmlHelper.ClientValidationEnabled = true;
            //HtmlHelper.UnobtrusiveJavaScriptEnabled = true;

            AreaRegistration.RegisterAllAreas();

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);

            DataAnnotationsModelValidatorProvider.RegisterAdapter(
                typeof(RemoteUID_Attribute),
                typeof(RemoteValidator));

            ControllerBuilder.Current.SetControllerFactory(new NinjectControllerFactory());

            ModelBinders.Binders.Add(typeof(Cart), new CartModelBinder());

            ModelBinders.Binders.Add(typeof(Appointment), new ValidatingModelBinder());
        }
        public void RegisterAdapterGuardClauses()
        {
            // Attribute type cannot be null
            Assert.ThrowsArgumentNull(
                () => DataAnnotationsModelValidatorProvider.RegisterAdapter(null, typeof(MyValidationAttributeAdapter)),
                "attributeType");

            // Adapter type cannot be null
            Assert.ThrowsArgumentNull(
                () => DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(MyValidationAttribute), null),
                "adapterType");

            // Validation attribute must derive from ValidationAttribute
            Assert.Throws <ArgumentException>(
                () => DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(object), typeof(MyValidationAttributeAdapter)),
                "The type System.Object must derive from System.ComponentModel.DataAnnotations.ValidationAttribute\r\nParameter name: attributeType");

            // Adapter must derive from ModelValidator
            Assert.Throws <ArgumentException>(
                () => DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(MyValidationAttribute), typeof(object)),
                "The type System.Object must derive from System.Web.Mvc.ModelValidator\r\nParameter name: adapterType");

            // Adapter must have the expected constructor
            Assert.Throws <ArgumentException>(
                () => DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(MyValidationAttribute), typeof(MyValidationAttributeAdapterBadCtor)),
                "The type System.Web.Mvc.Test.DataAnnotationsModelValidatorProviderTest+MyValidationAttributeAdapterBadCtor must have a public constructor which accepts three parameters of types System.Web.Mvc.ModelMetadata, System.Web.Mvc.ControllerContext, and System.Web.Mvc.Test.DataAnnotationsModelValidatorProviderTest+MyValidationAttribute\r\nParameter name: adapterType");
        }
コード例 #21
0
 public static void SelfRegister()
 {
     DataAnnotationsModelValidatorProvider
     .RegisterAdapter(
         typeof(DynamicRangeAttribute),
         typeof(DynamicRangeAttributeAdapter));
 }
コード例 #22
0
        public static void RegisterAdapters()
        {
            Type adapterType = typeof(LocalizedDataAnnotationsValidator);

            DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(RequiredAttribute), adapterType);
            DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(DataTypeAttribute), adapterType);
            DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(MaxLengthAttribute), adapterType);
        }
コード例 #23
0
        private static void InitializCustomValidationAttributes()
        {
            DataAnnotationsModelValidatorProvider.RegisterAdapter(
                typeof(RequiredFieldAttribute), typeof(RequiredAttributeAdapter));

            DataAnnotationsModelValidatorProvider.RegisterAdapter(
                typeof(StringLengthRangeAttribute), typeof(System.Web.Mvc.StringLengthAttributeAdapter));
        }
コード例 #24
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterRoutes(RouteTable.Routes);

            DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(BoolTypeAttribute), typeof(BoolTypeValidator));
        }
コード例 #25
0
        public static void Kick()
        {
            // Create script bundle for Mkay.
            BundleTable.Bundles.Add(new ScriptBundle("~/bundles/mkay").Include("~/Scripts/mkay*"));

            // Hook up MkayAttribute to use its own validator which sets ValidationContext.MemberName.
            DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(MkayAttribute), typeof(MkayValidator));
        }
コード例 #26
0
ファイル: Startup.cs プロジェクト: governmentbg/NPPD-INSPIRE
        private static void AppStart()
        {
            ////Scripts.DefaultTagFormat = @"<script src=""{0}"" async></script>";
            Styles.DefaultTagFormat = @"<link href=""{0}"" rel=""stylesheet"" async/>";

            MvcHandler.DisableMvcResponseHeader = true;

            AreaRegistration.RegisterAllAreas();

            ViewEngines.Engines.Clear();
            ViewEngines.Engines.Add(new RazorViewEngine {
                FileExtensions = new[] { "cshtml" }
            });

            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            BundleTable.EnableOptimizations = false;
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            BindersConfig.RegisterModelBinders(ModelBinders.Binders);

            // Create controller with localization - before model bind
            ControllerBuilder.Current.SetControllerFactory(
                new DefaultControllerFactory(new LocalizationControllerActivator()));

            // Remove and JsonValueProviderFactory and add JsonDotNetValueProviderFactory
            if (ConfigurationReader.ChangeDefaultJsonValueProviderFactory)
            {
                ValueProviderFactories.Factories.Remove(
                    ValueProviderFactories
                    .Factories.OfType <JsonValueProviderFactory>().FirstOrDefault());
                ValueProviderFactories.Factories.Add(new JsonDotNetValueProviderFactory());
            }

            // Add client validation localization - for this moment is only for DateType and RequiredAttribute
            ClientDataTypeModelValidatorProvider.ResourceClassKey = "Resource";
            DefaultModelBinder.ResourceClassKey = "Resource";

            DataAnnotationsModelValidatorProvider.AddImplicitRequiredAttributeForValueTypes = false;
            DataAnnotationsModelValidatorProvider.RegisterAdapter(
                typeof(RequiredAttribute),
                typeof(LocalizationRequiredAttributeAdapter));

            AntiForgeryConfig.SuppressIdentityHeuristicChecks = true;

            ServicePointManager.ServerCertificateValidationCallback = (s, certificate, chain, sslPolicyErrors) => true;

            // Changed default model binder - may to use custom property binder as attribute in view model. Example is decrypting of ids
            ModelBinders.Binders.DefaultBinder = new ExtendedModelBinder();
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            // If you have enabled SSL. Uncomment this line to ensure that the Anti-Forgery
            // cookie requires SSL to be sent across the wire.
            AntiForgeryConfig.RequireSsl = ConfigurationReader.AntiForgeryConfigRequireSsl;

            // Rename the Anti-Forgery cookie from "__RequestVerificationToken" to "f".
            // This adds a little security through obscurity and also saves sending a
            // few characters over the wire.
            AntiForgeryConfig.CookieName = "f";
        }
コード例 #27
0
 /// <summary>
 /// Registers all NLib adapters.
 /// </summary>
 public static void RegisterAllNLibAdapter()
 {
     DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(EqualsToAttribute), typeof(EqualsToAttributeAdapter));
     DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(GreaterThanAttribute), typeof(GreaterThanAttributeAdapter));
     DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(GreaterThanOrEqualsToAttribute), typeof(GreaterThanOrEqualsToAttributeAdapter));
     DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(LessThanAttribute), typeof(LessThanAttributeAdapter));
     DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(LessThanOrEqualsToAttribute), typeof(LessThanOrEqualsToAttributeAdapter));
     DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(NotEqualsToAttribute), typeof(NotEqualsToAttributeAdapter));
 }
コード例 #28
0
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(RequiredIfAttribute), typeof(RequiredIfValidator));
     DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(AssertThatAttribute), typeof(AssertThatValidator));
 }
コード例 #29
0
 public static void Register()
 {
     DefaultModelBinder.ResourceClassKey = "Messages";
     DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(RequiredAttribute), typeof(CustomRequiredAttributeAdapter));
     DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(MinLengthAttribute), typeof(CustomMinLengthAttributeAdapter));
     DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(MaxLengthAttribute), typeof(CustomMaxLengthAttributeAdapter));
     DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(System.ComponentModel.DataAnnotations.CompareAttribute), typeof(CustomCompareAttributeAdapter));
     DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(EmailAddressAttribute), typeof(CustomEmailAddressAttributeAdapter));
 }
コード例 #30
0
        protected void Application_Start()
        {
            KSU.maxGameSeason   = Convert.ToInt16(System.Configuration.ConfigurationManager.AppSettings["maxGameSeason"].ToString());
            KSU.maxPlayerSeason = Convert.ToInt16(System.Configuration.ConfigurationManager.AppSettings["maxPlayerSeason"].ToString());

            RegisterRoutes(RouteTable.Routes);

            DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(EmailAttribute), typeof(EmailValidator));
        }