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()); } }
public void RegisterAreaEmbeddedResources() { var areaType = GetType(); var resourceStore = new AssemblyResourceStore(areaType, "/areas/" + AreaName.ToLower(), areaType.Namespace, GetMap()); AssemblyResourceManager.RegisterAreaResources(resourceStore); }
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)); }
private static Dictionary <string, AssemblyResourceStore> InitializeAssemblyResourceStores() { var resourceStores = new Dictionary <string, AssemblyResourceStore>(); // Add default AssemblyResourceStore for input builders var inputBuildersStore = new AssemblyResourceStore(typeof(AssemblyResourceProvider), "/views/inputbuilders", "MvcContrib.UI.InputBuilder.Views.InputBuilders"); resourceStores.Add(inputBuildersStore.VirtualPath, inputBuildersStore); return(resourceStores); }
public void The_file_should_locate_a_embedded_resource() { //arrange var resourceStore = new AssemblyResourceStore(typeof(AssemblyResourceProvider), "", "MvcContrib.UI.InputBuilder"); var file = new AssemblyResourceVirtualFile("~/Views/InputBuilders/String.aspx", resourceStore); //act var result = file.Open(); //assert Assert.IsNotNull(result); }
public IResourceStore RetrieveResourceStore(Type evidence) { IResourceStore store = null; if (resourceStores.TryGetValue(evidence.AssemblyQualifiedName, out store) == false) { store = new AssemblyResourceStore(evidence); store = resourceStores.GetOrAdd(evidence.AssemblyQualifiedName, store); } return(store); }
public void The_file_should_not_locate_an_invalid_path() { //arrange var resourceStore = new AssemblyResourceStore(typeof(AssemblyResourceProvider), "", "MvcContrib.UI.InputBuilder"); var file = new AssemblyResourceVirtualFile("~/foo", resourceStore); //act var result = file.Open(); //assert Assert.IsNull(result); }
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])); } }
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])); } }
public ActionResult Index(string resourceName, string resourcePath) { if (!string.IsNullOrEmpty(resourcePath)) { resourceName = "~/" + resourcePath + "." + resourceName; } var areaName = (string)RouteData.DataTokens["area"]; AssemblyResourceStore resourceStore = AssemblyResourceManager.GetResourceStoreForArea(areaName); // pre-pend "~" so that it will be replaced with assembly namespace Stream resourceStream = resourceStore.GetResourceStream(resourceName); var minfy = new SeajsMinify(); if (resourceStream == null) { Response.StatusCode = 404; return(null); } string contentType = GetContentType(resourceName); return(File(resourceStream, contentType)); }
public AssemblyResourceVirtualFile(string virtualPath, AssemblyResourceStore resourceStore, string embedVirtualPath) : base(virtualPath) { this.resourceStore = resourceStore; this.path = embedVirtualPath; }
public AssemblyResourceVirtualFile(string virtualPath, AssemblyResourceStore resourceStore) : base(virtualPath) { this.resourceStore = resourceStore; this.path = VirtualPathUtility.ToAppRelative(virtualPath); }
public static void RegisterAreaResources(AssemblyResourceStore assemblyResourceStore) { assemblyResourceStores.Add(assemblyResourceStore.VirtualPath, assemblyResourceStore); }