public string BuildBundleContent(string filePath, string areaName, BundleContext context) { if (areaName == null) { throw new OrnamentException("Cannot find areaName in virtual path " + filePath); } areaName = areaName.ToLower(); filePath = filePath.ToLower(); AssemblyResourceStore resourceStoreForArea = AssemblyResourceManager.GetResourceStoreForArea(areaName); if (!filePath.StartsWith("~/areas/")) { filePath = "~/areas" + filePath.TrimStart(new[] { '~' }); } Stream resourceStream = resourceStoreForArea.GetResourceStream(filePath); if (resourceStream == null) { return(string.Format("console.log('Cannot find embed file {0} in {1} assembly')", resourceStoreForArea.GetFullyQualifiedTypeFromPath(filePath), areaName)); } using (var reader = new StreamReader(resourceStream)) { return(reader.ReadToEnd()); } }
protected void ResgistSeajsFiles(IApplicationBus bus) { foreach (SeajsModel model in _seajsEmbeddedModulePath) { string str = string.Format("{0}/{1}", _context.AreaName, model.BundleNamee); string[] strArray = AssemblyResourceManager.GetResourceStoreForArea(_context.AreaName) .MatchPath("~/" + model.FilePath, ".js"); if ((strArray == null) || (strArray.Length == 0)) { throw new FileNotFoundException(string.Format("Not found an embed js file in {0}", str)); } foreach (string str2 in strArray) { var bundle = new SeajsEmbedBundle(string.Format("~/{0}/{1}", str, str2), _context.AreaName, OrnamentContext.Configuration.GetSeajsCombine()); if (model.BundleNamee != model.FilePath) { string virtualPath = string.Format("~/areas/{0}/{1}/{2}", _context.AreaName, model.FilePath, str2); bundle = (SeajsEmbedBundle)bundle.Include(virtualPath); } var eventMessage = new SeajsModuleBundleEventMessage(bundle); bus.Send(eventMessage); } } }
public void App_resource_path_should_find_input_builders() { //arrange/act var result = AssemblyResourceManager.IsEmbeddedViewResourcePath("~/Views/InputBuilders/String.aspx"); //assert Assert.IsTrue(result); }
private static ResourceSet GetPath(ViewContext page, string filePath, string pageName) { var areaName = (string)page.RouteData.DataTokens["area"]; AssemblyResourceStore resourceStore = AssemblyResourceManager.GetResourceStoreForArea(areaName); string defaultReex = resourceStore.GetFullyQualifiedTypeFromPath(string.Format(@"{0}/{1}.resources", filePath, pageName)); return(resourceStore.GetMultiLanguageResouce(defaultReex)); }
public override string GetCacheKey(string virtualPath) { var checkPath = GetTheEmbedPath(virtualPath); if (AssemblyResourceManager.IsEmbeddedViewResourcePath(checkPath)) { return(null); } return(base.GetCacheKey(virtualPath)); }
public override bool FileExists(string virtualPath) { bool flag = base.FileExists(virtualPath); if (!flag) { var checkPath = this.GetTheEmbedPath(virtualPath); return(AssemblyResourceManager.IsEmbeddedViewResourcePath(checkPath)); } return(flag); }
private void VerifiyAssemblyResourceStoreIsPathResourceStream(string areaName) { AssemblyResourceStore store; InitializeEmbeddedResourceController(areaName); store = AssemblyResourceManager.GetResourceStoreForArea(areaName); store.ShouldNotBeNull(); store.IsPathResourceStream("~/Images/arrow.gif").ShouldBeTrue(); store.IsPathResourceStream("~/Images/Missing_Image.gif").ShouldBeFalse(); }
public override System.Web.Caching.CacheDependency GetCacheDependency(string virtualPath, System.Collections.IEnumerable virtualPathDependencies, DateTime utcStart) { if (AssemblyResourceManager.IsEmbeddedViewResourcePath(virtualPath)) { return(null); } else { string[] dependencies = virtualPathDependencies.OfType <string>().Where(s => !s.ToLower().Contains("/views/inputbuilders")).ToArray(); return(base.GetCacheDependency(virtualPath, dependencies, utcStart)); } }
public override VirtualFile GetFile(string virtualPath) { if (AssemblyResourceManager.IsEmbeddedViewResourcePath(virtualPath) && !base.FileExists(virtualPath)) { var resourceStore = AssemblyResourceManager.GetResourceStoreFromVirtualPath(virtualPath); return(new AssemblyResourceVirtualFile(virtualPath, resourceStore)); } else { return(base.GetFile(virtualPath)); } }
public static void BootStrap() { if (!ViewEngines.Engines.Any(engine => engine.GetType().Equals(typeof(InputBuilderViewEngine)))) { VirtualPathProvider pathProvider = new AssemblyResourceProvider(); RegisterPathProvider(pathProvider); var resourceStore = new AssemblyResourceStore(typeof(PortableAreaRegistration), "/areas", typeof(PortableAreaRegistration).Namespace); AssemblyResourceManager.RegisterAreaResources(resourceStore); ViewEngines.Engines.Add(new InputBuilderViewEngine(new string[0])); } }
private void SetLoggerConfiguration() { try { if (File.Exists("nlog.config")) { LogManager.Configuration = new XmlLoggingConfiguration(XmlReader.Create(File.OpenRead("nlog.config"))); return; } } catch { // Cannot create logger } LogManager.Configuration = new XmlLoggingConfiguration(XmlReader.Create(AssemblyResourceManager.GetResourceStream("XOutput.Server.nlog.config"))); }
public override CacheDependency GetCacheDependency(string virtualPath, IEnumerable virtualPathDependencies, DateTime utcStart) { foreach (object obj2 in virtualPathDependencies) { var checkpath = GetTheEmbedPath(obj2.ToString()); if (AssemblyResourceManager.IsEmbeddedViewResourcePath(checkpath)) { return(null); } } string[] strArray = (from s in virtualPathDependencies.OfType <string>() where !s.ToLower().Contains("/views/inputbuilders") select s).ToArray <string>(); return(base.GetCacheDependency(virtualPath, strArray, utcStart)); }
public static bool IsAssemblyCombineModules(string uniqureId) { RouteData routeDataByUrl = RouteUtils.GetRouteDataByUrl(uniqureId); if (routeDataByUrl == null) { return(false); } var areaName = (string)routeDataByUrl.DataTokens["area"]; if (areaName == null) { return(false); } if (AssemblyResourceManager.GetResourceStoreForArea(areaName) == null) { return(false); } return(BundleTable.Bundles.GetBundleFor(uniqureId) is SeajsEmbedBundle); }
public override VirtualFile GetFile(string virtualPath) { string str; string embedPath = virtualPath; if (IsCrosssAssemblyPath(embedPath, out str)) { embedPath = str; } var assemblyStore = AssemblyResourceManager.GetResourceStoreFromVirtualPath(embedPath); if (assemblyStore != null) { if (embedPath == virtualPath) { return(new AssemblyResourceVirtualFile(virtualPath, assemblyStore)); } return(new AssemblyResourceVirtualFile(virtualPath, assemblyStore, embedPath)); } return(base.GetFile(virtualPath)); }
public ActionResult Index(string resourceName, string resourceType) { if (!string.IsNullOrEmpty(resourceType)) { resourceName = "Content" + "." + resourceType + "." + resourceName; } var areaName = (string)RouteData.DataTokens["area"]; var resourceStore = AssemblyResourceManager.GetResourceStoreForArea(areaName); // pre-pend "~" so that it will be replaced with assembly namespace var resourceStream = resourceStore.GetResourceStream("~." + resourceName); if (resourceStream == null) { Response.StatusCode = 404; return(null); } var contentType = GetContentType(resourceName); return(File(resourceStream, contentType)); }
public override void Handle(DBScriptsMessage message) { var version = message.LastVersion; var connectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; var currentVersion = ExecuteScripts.ExecuteHelper.GetLastDBVersion(connectionString, message.AreaName); //I get temp directory from filesystem string tempPath = System.IO.Path.GetTempPath(); DirectoryInfo directory = new DirectoryInfo(tempPath); var scriptsDirectoryName = Guid.NewGuid().ToString(); var scriptsDirectory = directory.CreateSubdirectory(scriptsDirectoryName); Encoding encoding = Encoding.GetEncoding("ISO-8859-1"); //I keep al the valid scripts (newer than current version for this area) foreach (var script in message.Scripts.Where(s => s.Version.CompareTo(currentVersion) > 0)) { var fileStream = AssemblyResourceManager.GetResourceStoreForArea(message.AreaName).GetResourceStream(script.Url); //Save all scripts into temporary folder using (StreamReader fileReader = new StreamReader(fileStream)) { var fileContent = fileReader.ReadToEnd(); var fileData = script.Version.Split(new char[] { '_' }); var scriptsDateFolder = scriptsDirectory.FullName + "/" + fileData[0]; if (!Directory.Exists(scriptsDateFolder)) { scriptsDirectory.CreateSubdirectory(fileData[0]); } File.WriteAllText(scriptsDateFolder + "/" + fileData[1] + ".sql", fileContent, encoding); } } //Call execute scripts helper in order to update db for this area ExecuteScripts.ExecuteHelper.Execute(scriptsDirectory.FullName, connectionString, message.AreaName); }
private void SetLoggerConfiguration() { try { if (File.Exists("nlog.config")) { LogManager.Configuration = new XmlLoggingConfiguration(XmlReader.Create(File.OpenRead("nlog.config"))); } } catch { LogManager.Configuration = new XmlLoggingConfiguration(XmlReader.Create(AssemblyResourceManager.GetResourceStream("nlog.config"))); } }
public override bool FileExists(string virtualPath) { bool exists = base.FileExists(virtualPath); return(exists ? exists : AssemblyResourceManager.IsEmbeddedViewResourcePath(virtualPath)); }