Exemple #1
0
        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());
            }
        }
Exemple #2
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));
        }