Exemplo n.º 1
0
        public static void InitAutoMapper()
        {
            var cfg = new MapperConfigurationExpression();

            AutoMapperBLLConfiguration.Configure(cfg);
            AutoMapperWebConfiguration.Configure(cfg);
            Mapper.Initialize(cfg);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Also we have ability set different type of configuration throughout different bootstraper class (convention => name may be different)
        /// </summary>
        protected void Application_Start()
        {
            //Config WebAPI(2)
            GlobalConfiguration.Configure(WebApiConfig.Register);
            //WebApiConfig.Register(GlobalConfiguration.Configuration);

            //Order is verty important (if i reverse areaRegistration with WebApiConfig => WebAPI 2 attributeRouting won't work
            AreaRegistration.RegisterAllAreas();

            // This method call registers all filters
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            /* Work only with razor View Engine
             * {0} represents the name of the view.
             * {1} represents the name of the controller.
             * {2} represents the name of the area.
             */
            ViewEngines.Engines.Clear();
            /*Avoid searched each view instead in .cshtml files*/
            ViewEngines.Engines.Add(new RazorViewEngine()
            {
                ViewLocationFormats            = new[] { "~/Views/{1}/{0}.cshtml", "~/Views/Shared/{0}.cshtml" },
                PartialViewLocationFormats     = new[] { "~/Views/{1}/{0}.cshtml", "~/Views/Shared/{0}.cshtml" },
                MasterLocationFormats          = new[] { "~/Views/{1}/{0}.cshtml", "~/Views/Shared/{0}.cshtml" },
                AreaViewLocationFormats        = new[] { "~/Areas/{2}/Views/{1}/{0}.cshtml", "~/Areas/{2}/Views/Shared/{0}.cshtml" },
                AreaMasterLocationFormats      = new[] { "~/Areas/{2}/Views/{1}/{0}.cshtml", "~/Areas/{2}/Views/Shared/{0}.cshtml" },
                AreaPartialViewLocationFormats = new[] { "~/Areas/{2}/Views/{1}/{0}.cshtml", "~/Areas/{2}/Views/Shared/{0}.cshtml" }
            });

            BundleConfig.RegisterBundles(BundleTable.Bundles);

            //registration custom binding providers with links to vm
            //ModelBinders.Binders.Add(typeof(SessionStorage), new StorageTableModelBinder());
            //ModelBinders.Binders.Add(typeof(InputMenuViewModel), new InputMenuModelBinder());

            //MVC4 Quick Tip #3–Removing the XML Formatter from ASP.Net Web API
            //GlobalConfiguration.Configuration.Formatters.XmlFormatter.SupportedMediaTypes.Clear();

            //Configure AutoMapper
            AutoMapperBLLConfiguration.Configure();

            //https://github.com/doceandyou/Log4Net
            log4net.Config.XmlConfigurator.Configure(new FileInfo(this.Server.MapPath("~/Web.config")));

            /* Initialize simpleMembership
             * Install-Package Microsoft.AspNet.WebHelpers
             * Install-Package Microsoft.AspNet.WebPages.Data
             * (stop: required dependencies to Microsoft.AspNet.Razor > 3.0 => .Net 4.5
             * WebSecurity.InitializeDatabaseConnection("SecurityConnection", "UserProfile", "UserId", "UserName", true);
             */

            /*Custom value provider (order sense)
             * (First)
             * ValueProviderFactories.Factories.Insert(0,new CustomValueProviderFactory());
             * (End)
             * ValueProviderFactories.Factories.Add(new CustomValueProviderFactory());
             */

            /*Controller Builder
             * ControllerBuilder.Current.DefaultNamespaces.Add("DefaultNamespace");
             */

            //users online
            AppStateHelper.Set(AppStateKeys.ONLINE, 0);
        }