示例#1
0
        public void MapPathTest()
        {
            var serverPath = _defaultVirtualPathProvider.MapPath("~/bin");
            var localPath  = _defaultVirtualPathProvider.MapPath("/bin");

            Assert.Equal(serverPath, Path.Combine(_currentRootPath, "bin"));
            Assert.Equal(localPath, Path.Combine(_currentRootPath, "bin"));
        }
        protected virtual void Application_Start(object sender, EventArgs e)
        {
            var stopwatch = new Stopwatch();

            stopwatch.Start();
            PerWebRequestLifestyleModule.FuncHttpCache = (noInput) => { return(HttpContext.Current.Items); };

            AbpBootstrapper.IocManager.IocContainer.AddFacility <Castle.Facilities.Logging.LoggingFacility>(
                f => Blocks.Framework.Logging.Log4Net.LoggingFacilityExtensions.UseLog4Net(f).WithConfig(Server.MapPath(logConfigName))
                );

            ThreadCultureSanitizer.Sanitize();

            var environment = WebHostingEnvironment.CreateHostingEnvironment(new WebHostingEnvironment()
            {
                ContentRootPath = Server.MapPath("~")
            });
            IVirtualPathProvider pathProvider = new DefaultVirtualPathProvider(environment);

            if (pathProvider.DirectoryExists(@"~\Modules"))
            {
                foreach (var modulePath in pathProvider.ListDirectories(@"~\Modules"))
                {
                    var moduleFileList = pathProvider.ListDirectories(modulePath);
//                    if (!moduleFileList.Any(t => string.Equals(t, "Module.txt", StringComparison.CurrentCultureIgnoreCase)))
//                        continue;
                    var moduleBin = moduleFileList.FirstOrDefault(t => t.EndsWith("bin"));
                    moduleBin = moduleBin ?? moduleFileList.FirstOrDefault(t => t.EndsWith("Release"));
                    if (!string.IsNullOrEmpty(moduleBin))
                    {
                        AbpBootstrapper.PlugInSources.AddFolder(pathProvider.MapPath(moduleBin),
                                                                SearchOption.AllDirectories);
                    }
                }
            }

            AbpBootstrapper.Initialize();

            stopwatch.Stop();

            LogHelper.Log(new LogModel()
            {
                Message = "Framework Init time:" + stopwatch.ElapsedMilliseconds + "ms", LogSeverity = LogSeverity.Info
            });
        }
        protected virtual void Application_Start(object sender, EventArgs e)
        {
            AbpBootstrapper.IocManager.IocContainer.AddFacility <LoggingFacility>(
                f => f.UseAbpLog4Net().WithConfig(Server.MapPath(logConfigName))
                );

            ThreadCultureSanitizer.Sanitize();

            var environment = WebHostingEnvironment.CreateHostingEnvironment(new WebHostingEnvironment()
            {
                ContentRootPath = Server.MapPath("~")
            });
            IVirtualPathProvider pathProvider = new DefaultVirtualPathProvider(environment);

            if (pathProvider.DirectoryExists(@"~\Modules"))
            {
                AbpBootstrapper.PlugInSources.AddFolder(pathProvider.MapPath(@"~\Modules"),
                                                        SearchOption.AllDirectories);
            }
            AbpBootstrapper.Initialize();
            PerWebRequestLifestyleModule.FuncHttpCache = (noInput) => { return(HttpContext.Current.Items); };
        }