public void CreateAndUpdateAndListFile_CreateAndUpdateAndListDirectory() { var directoryName = Guid.NewGuid().ToString(); var fileName = directoryName + "/" + Guid.NewGuid().ToString(); try { _defaultVirtualPathProvider.CreateDirectory(directoryName); Assert.True(_defaultVirtualPathProvider.DirectoryExists(directoryName)); using (var fileStream = _defaultVirtualPathProvider.CreateText(fileName)) { fileStream.WriteLine(string.Empty); } Assert.True(_defaultVirtualPathProvider.FileExists(fileName)); Assert.Equal(1, _defaultVirtualPathProvider.ListFiles(directoryName).Count()); } finally { foreach (var fileInfo in _defaultVirtualPathProvider.ListFiles(directoryName)) { _defaultVirtualPathProvider.DeleteFile(fileInfo); } _defaultVirtualPathProvider.DeleteDirectory(directoryName); } }
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); }; }