Ejemplo n.º 1
0
        public override System.Collections.Generic.IEnumerable <System.IO.FileInfo> EnumerateFiles(BundleContext context)
        {
            foreach (var file in _wrapped.EnumerateFiles(context))
            {
                if (IncludeFilename(file.Name))
                {
                    yield return(file);
                }
            }

            foreach (var file in base.EnumerateFiles(context))
            {
                yield return(file);
            }
        }
Ejemplo n.º 2
0
          private async static void GenerateBundleJS(ScriptBundle scriptBundle, BundleCollection bundles)
        {
            string bundleOutputPath = Path.Combine(HttpRuntime.AppDomainAppPath, BundleOutputFile);
            BundleContext context = new BundleContext(new HttpContextWrapper(HttpContext.Current), bundles, ScriptsBundleVirtualPath);
            System.Text.StringBuilder fileSpacer = new System.Text.StringBuilder();

            try
            {
                using (StreamWriter outputStream = new StreamWriter(bundleOutputPath))
                {
                    outputStream.BaseStream.Seek(0, SeekOrigin.End);
                    System.Collections.Generic.List<string> filePaths = PrepareFileList(scriptBundle.EnumerateFiles(context));

                    foreach (string filePath in filePaths)
                    {
                        string fileSpacerText = BuildFileSpacer(fileSpacer, filePath);

                        await outputStream.WriteAsync(fileSpacerText);

                        using (StreamReader jsFileStream = new StreamReader(filePath))
                        {
                            await outputStream.WriteAsync(await jsFileStream.ReadToEndAsync());
                        }
                    }
                }
            }
            catch (System.NullReferenceException nullEx)
            {
                string error = nullEx.Message;
            }
        }