public override BundleResponse GenerateBundleResponse(BundleContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            if (!BundleTable.EnableOptimizations)
            {
                return(new BundleResponse(string.Empty, new List <BundleFile>()));
            }

            var bundleFiles  = EnumerateFiles(context);
            var ignoredFiles = context.BundleCollection.IgnoreList.FilterIgnoredFiles(context, bundleFiles);
            var files        = Orderer.OrderFiles(context, ignoredFiles).ToList();

            if (string.IsNullOrWhiteSpace(_options.WorkingDir))
            {
                _options.WorkingDir = "/";
            }

            var compiler     = new TemplateCompiler(_options);
            var virtualFiles = files.Select(f => f.VirtualFile).ToArray();
            var result       = compiler.Compile(virtualFiles);

            return(ApplyTransforms(context, result, files));
        }
示例#2
0
        /// <summary>
        /// Processes the bundle request to generate the response.
        /// </summary>
        /// <param name="context">The <see cref="BundleContext"/> object that contains state for both the framework configuration and the HTTP request.</param>
        /// <returns>A <see cref="BundleResponse"/> object containing the processed bundle contents.</returns>
        /// <remarks>
        /// Generating the bundle response is accomplished based on the following steps:
        /// 1. Enumerates the contents of the bundle.
        /// 2. Filters the files using the IgnoreList
        /// 3. Orders the files.
        /// 4. Chooses any replacements using the FileExtensionReplacementList.
        /// 5. Builds the bundle content using the Builder.
        /// 6. Transforms the bundle using the Transform.
        /// </remarks>
        public virtual BundleResponse GenerateBundleResponse(BundleContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            IEnumerable <BundleFile> bundleFiles = EnumerateFiles(context);

            bundleFiles = context.BundleCollection.IgnoreList.FilterIgnoredFiles(context, bundleFiles);
            bundleFiles = Orderer.OrderFiles(context, bundleFiles);
            if (EnableFileExtensionReplacements)
            {
                bundleFiles = context.BundleCollection.FileExtensionReplacementList.ReplaceFileExtensions(context, bundleFiles);
            }
            string bundleContent = Builder.BuildBundleContent(this, context, bundleFiles);

            return(ApplyTransforms(context, bundleContent, bundleFiles));
        }