Ejemplo n.º 1
0
        // See LocatorStartup for lots of pre-startup IoC setup that's performed.

        public void Configuration(IAppBuilder app)
        {
            var appSettings = LocatorStartup.Locator.GetInstance <ApplicationSettings>();

            app.Use <InstallCheckMiddleware>(appSettings);

            // Register the "/Attachments/" route handler. This needs to be called before the other routing setup.
            if (appSettings.Installed)
            {
                // InstallService.Install also performs this
                var fileService = LocatorStartup.Locator.GetInstance <IFileService>();
                AttachmentRouteHandler.RegisterRoute(appSettings, RouteTable.Routes, fileService);
            }

            // Filters
            GlobalFilters.Filters.Add(new HandleErrorAttribute());

            // Areas are used for Site settings (for a cleaner view structure)
            // This should be called before the other routes, for some reason.
            AreaRegistration.RegisterAllAreas();

            // Register routes
            Routing.RegisterApi(GlobalConfiguration.Configuration);
            Routing.Register(RouteTable.Routes);

            // Custom view engine registration (to add directory search paths for Theme views)
            ExtendedRazorViewEngine.Register();

            app.UseWebApi(new HttpConfiguration());


            Log.Information("Application started");
        }
Ejemplo n.º 2
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            //自定义View
            ViewEngines.Engines.Clear();
            ExtendedRazorViewEngine engine = new ExtendedRazorViewEngine();

            engine.AddPartialViewLocationFormat("~/Areas/Common/Views/Shared/{0}.cshtml");
            engine.AddPartialViewLocationFormat("~/Areas/Common/Views/Shared/{0}.vbhtml");
            ViewEngines.Engines.Add(engine);

            //Model去除前后空格
            ModelBinders.Binders.DefaultBinder = new TrimModelBinder();

            //设置MEF依赖注入容器
            MefConfig.RegisterMef();

            //初始化DB
            DatabaseInitializer.Initialize(); //在项目第一运行就需要初始数,到后面数据有的就不需要了
        }
Ejemplo n.º 3
0
        private void ExtendRazorViewEngineUsedToLocateViews()
        {
            ViewEngines.Engines.Clear();

            // Customize the View Engine to add a new location to look for Views (under the Presentation Folder):
            var engine = new ExtendedRazorViewEngine();

            engine.AddMasterLocationFormat("~/Presentation/Views/{1}/{0}.cshtml");
            engine.AddMasterLocationFormat("~/Presentation/Shared/{0}.cshtml");
            engine.AddViewLocationFormat("~/Presentation/Views/{1}/{0}.cshtml");
            engine.AddViewLocationFormat("~/Presentation/Views/Shared/{0}.cshtml");
            engine.AddPartialViewLocationFormat("~/Presentation/Views/{1}/{0}.cshtml");
            engine.AddPartialViewLocationFormat("~/Presentation/Shared/{0}.cshtml");

            //Don't need to add the default locations as they are already in the new Engine by default...
            //engine.AddMasterLocationFormat("~/Views/{1}/{0}.cshtml");
            //engine.AddMasterLocationFormat("~/Shared/{0}.cshtml");
            //engine.AddViewLocationFormat("~/Views/{1}/{0}.cshtml");
            //engine.AddViewLocationFormat("~/Views/Shared/{0}.cshtml");
            //engine.AddPartialViewLocationFormat("~/Views/{1}/{0}.cshtml");
            //engine.AddPartialViewLocationFormat("~/Shared/{0}.cshtml");

            ViewEngines.Engines.Add(engine);

            // Now add the following to any App.ModuleN.Application assembly where you put the Views.
            //
            //    < ItemGroup >
            //    < EmbeddedResource Include = "Views/**/*.cshtml" />
            //    </ ItemGroup >
        }
Ejemplo n.º 4
0
        protected void Application_Start()
        {
            // Get the settings from the web.config
            ConfigReaderWriter  configReader        = new FullTrustConfigReaderWriter("");
            ApplicationSettings applicationSettings = configReader.GetApplicationSettings();

            // Configure StructureMap dependencies
            DependencyManager iocSetup = new DependencyManager(applicationSettings);

            iocSetup.Configure();
            iocSetup.ConfigureMvc();

            // Logging
            Log.ConfigureLogging(applicationSettings);

            // Filters
            GlobalFilters.Filters.Add(new HandleErrorAttribute());

            // Areas are used for:
            // - Site settings (for a cleaner view structure)
            // - Webapi help.
            // This should be called before the other routes, for some reason.
            AreaRegistration.RegisterAllAreas();

            // Register routes and JS/CSS bundles
            Routing.RegisterApi(GlobalConfiguration.Configuration);
            Routing.Register(RouteTable.Routes);
            Bundles.Register();

            // Custom view engine registration (to add new search paths)
            ExtendedRazorViewEngine.Register();

            Log.Information("Application started");
        }
Ejemplo n.º 5
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            //自定义View
            ViewEngines.Engines.Clear();
            ExtendedRazorViewEngine engine = new ExtendedRazorViewEngine();

            engine.AddPartialViewLocationFormat("~/Areas/Common/Views/Shared/{0}.cshtml");
            engine.AddPartialViewLocationFormat("~/Areas/Common/Views/Shared/{0}.vbhtml");
            ViewEngines.Engines.Add(engine);

            //Model去除前后空格
            ModelBinders.Binders.DefaultBinder = new TrimModelBinder();

            //设置MEF依赖注入容器
            MefConfig.RegisterMef();

            String configfilename = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;

            RemotingConfiguration.Configure(configfilename);

            //初始化DB
            //  DatabaseInitializer.Initialize();
        }
Ejemplo n.º 6
0
        protected void Application_Start()
        {
            //-----------------------------------------------------------
            ViewEngines.Engines.Clear();

            ExtendedRazorViewEngine engine = new ExtendedRazorViewEngine();

            engine.AddViewLocationFormat("~/Views/{1}/{0}.cshtml");
            engine.AddViewLocationFormat("~/Views/{1}/{0}.vbhtml");

            // Add a shared location too, as the lines above are controller specific
            engine.AddPartialViewLocationFormat("~/Views/Shared/Theme/{0}.cshtml");
            engine.AddPartialViewLocationFormat("~/Views/Shared/Theme/{0}.vbhtml");
            engine.AddPartialViewLocationFormat("~/Views/Shared/FormInputs/{0}.cshtml");
            engine.AddPartialViewLocationFormat("~/Views/Shared/FormInputs/{0}.vbhtml");
            engine.AddPartialViewLocationFormat("~/Views/Shared/Theme/AsideMenu/{0}.cshtml");
            engine.AddPartialViewLocationFormat("~/Views/Shared/Theme/AsideMenu/{0}.vbhtml");
            engine.AddPartialViewLocationFormat("~/Views/Shared/Theme/HeaderTopbarItems/{0}.cshtml");
            engine.AddPartialViewLocationFormat("~/Views/Shared/Theme/HeaderTopbarItems/{0}.vbhtml");

            ViewEngines.Engines.Add(engine);
            //-----------------------------------------------------------

            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
        }
Ejemplo n.º 7
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

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

            SetupControllerBuilderNamespaces();
            SetupMetadataProviders();
            SetupValidatorProviders();

            //var models = ReflectionHelper.Instance.GetTypesFromAssembly("Pfizer.Web")
            //    .Where(type => type.GetCustomAttributes(typeof (ValidatorAttribute), true).FirstOrDefault() != null)
            //    .ToList();

            //models.ForEach(type=>ModelBinders.Binders.Add(type, new StringModelBinder()));


            var engine = new ExtendedRazorViewEngine();

            //engine.AddViewLocationFormat(string.Format("{0}.Proposal/Views/{0}.cshtml", area));
            // Add a shared location too, as the lines above are controller specific
            engine.AddPartialViewLocationFormat("~/Areas/Common/Views/Shared/{0}.cshtml");

            ViewEngines.Engines.Add(engine);
        }
Ejemplo n.º 8
0
        protected void Setup_Templates()
        {
            ViewEngines.Engines.Clear();

            ExtendedRazorViewEngine engine = new ExtendedRazorViewEngine();

            engine.AddViewLocationFormat("~/Templates/{1}/{0}.cshtml");

            // Add a shared location too, as the lines above are controller specific
            engine.AddPartialViewLocationFormat("~/Templates/{0}.cshtml");

            ViewEngines.Engines.Add(engine);
        }