public StringBuilder ProcessGroups(IPathProvider pathProvider, IJsCrusher jsCrusher, JsGroupElementCollection jsGroups)
        {
            var output = new StringBuilder("Js Files created:\r\n");

            Action<JsGroupToProcess> processJsGroup = ProcessJsGroup;

            var jsGroupsToProcess = jsGroups.Cast<JsGroupElement>()
                .Select(group => new JsGroupToProcess
                {
                    Crusher = jsCrusher,
                    PathProvider = pathProvider,
                    Group = group,
                    Output = output
                }).ToList();

            if (jsGroupsToProcess.Any())
            {
                ParallelExecute.EachParallel(jsGroupsToProcess, processJsGroup);
            }
            else
            {
                output.AppendFormat("No files to process");
            }
            return output;
        }
Beispiel #2
0
        private CrusherManager()
        {
            var crusherConfiguration = CurrentCrusherConfiguration.Current;

            _hashQueryStringKeyName = crusherConfiguration.QuerystringKeyName;
            _cssGroups = crusherConfiguration.CssGroups;
            _jsGroups  = crusherConfiguration.JsGroups;

            var retryableFileOpener = new RetryableFileOpener();
            var hasher = new Hasher(retryableFileOpener);
            var retryableFileWriter = new RetryableFileWriter(BufferSize, _encoding, retryableFileOpener, hasher);

            _pathProvider = new PathProvider();
            var cssAssetsFileHasher = new CssAssetsFileHasher(_hashQueryStringKeyName, hasher, _pathProvider);
            var cssPathRewriter     = new CssPathRewriter(cssAssetsFileHasher, _pathProvider);

            var cacheManager = new HttpCacheManager();

            var jsSpriteMetaDataFileInfo = new FileInfo("js.metadata");
            var jsMetaData = new SingleFileMetaData(jsSpriteMetaDataFileInfo, retryableFileOpener, retryableFileWriter);

            var cssSpriteMetaDataFileInfo = new FileInfo("css.metadata");
            var cssMetaData = new SingleFileMetaData(cssSpriteMetaDataFileInfo, retryableFileOpener, retryableFileWriter);

            _cssCrusher = new CssCrusher(cacheManager, _pathProvider, retryableFileOpener, retryableFileWriter, cssPathRewriter, cssMetaData, crusherConfiguration.WatchAssets);
            _jsCrusher  = new JsCrusher(cacheManager, _pathProvider, retryableFileOpener, retryableFileWriter, jsMetaData);

            InitManager();
        }
        private CrusherManager()
        {
            var crusherConfiguration = CurrentCrusherConfiguration.Current;
            _hashQueryStringKeyName = crusherConfiguration.QuerystringKeyName;
            _cssGroups = crusherConfiguration.CssGroups;
            _jsGroups = crusherConfiguration.JsGroups;

            var retryableFileOpener = new RetryableFileOpener();
            var hasher = new Hasher(retryableFileOpener);
            var retryableFileWriter = new RetryableFileWriter(BufferSize, _encoding, retryableFileOpener, hasher);
            _pathProvider = new PathProvider();
            var cssAssetsFileHasher = new CssAssetsFileHasher(_hashQueryStringKeyName, hasher, _pathProvider);
            var cssPathRewriter = new CssPathRewriter(cssAssetsFileHasher, _pathProvider);

            var cacheManager = new HttpCacheManager();

            var jsSpriteMetaDataFileInfo = new FileInfo("js.metadata");
            var jsMetaData = new SingleFileMetaData(jsSpriteMetaDataFileInfo, retryableFileOpener, retryableFileWriter);

            var cssSpriteMetaDataFileInfo = new FileInfo("css.metadata");
            var cssMetaData = new SingleFileMetaData(cssSpriteMetaDataFileInfo, retryableFileOpener, retryableFileWriter);

            _cssCrusher = new CssCrusher(cacheManager, _pathProvider, retryableFileOpener, retryableFileWriter, cssPathRewriter, cssMetaData, crusherConfiguration.WatchAssets);
            _jsCrusher = new JsCrusher(cacheManager, _pathProvider, retryableFileOpener, retryableFileWriter, jsMetaData);

            InitManager();
        }
Beispiel #4
0
 private CrusherHelper()
 {
     CacheManager        = new HttpCacheManager();
     QuerystringKeyName  = CurrentCrusherConfiguration.Current.QuerystringKeyName;
     CssGroups           = CurrentCrusherConfiguration.Current.CssGroups;
     JsGroups            = CurrentCrusherConfiguration.Current.JsGroups;
     RetryableFileOpener = new RetryableFileOpener();
     Hasher = new Hasher(RetryableFileOpener);
 }
Beispiel #5
0
 private CrusherHelper()
 {
     CacheManager = new HttpCacheManager();
     QuerystringKeyName = CurrentCrusherConfiguration.Current.QuerystringKeyName;
     CssGroups = CurrentCrusherConfiguration.Current.CssGroups;
     JsGroups = CurrentCrusherConfiguration.Current.JsGroups;
     RetryableFileOpener = new RetryableFileOpener();
     Hasher = new Hasher(RetryableFileOpener);
 }
Beispiel #6
0
        private static void CreateCrushedFiles(IPathProvider pathProvider, CssGroupElementCollection cssGroups, JsGroupElementCollection jsGroups, CssCrusher cssCrusher, JsCrusher jsCrusher)
        {
            _cssOutput = "Css Files created:\r\n";
            foreach (CssGroupElement group in cssGroups)
            {
                var files = new List<CssFile>();

                foreach (CssFileElement cssFile in group.Files)
                {
                    var file = new CssFile()
                    {
                        CompressionType = cssFile.CompressionType,
                        FilePath = cssFile.FilePath
                    };
                    files.Add(file);
                }

                var outputUri = new Uri(pathProvider.ToAbsolute(group.OutputFilePath), UriKind.Relative);
                cssCrusher.AddFiles(outputUri, files, group.AppendHashToCssAsset);

                _cssOutput += outputUri + " (" + group.Name + ")\r\n";
                foreach (var cssFile in files)
                {
                    outputUri = new Uri(pathProvider.ToAbsolute(cssFile.FilePath), UriKind.Relative);
                    _cssOutput += "    " + outputUri + "\r\n";
                }
            }

            _jsOutput = "Js Files created:\r\n";
            foreach (JsGroupElement group in jsGroups)
            {
                var files = new List<JsFile>();

                foreach (JsFileElement cssFile in group.Files)
                {
                    var file = new JsFile()
                    {
                        CompressionType = cssFile.CompressionType,
                        FilePath = cssFile.FilePath
                    };
                    files.Add(file);
                }

                var outputUri = new Uri(pathProvider.ToAbsolute(group.OutputFilePath), UriKind.Relative);
                jsCrusher.AddFiles(outputUri, files);

                _jsOutput += outputUri + " (" + group.Name + ")\r\n";
                foreach (var jsFile in files)
                {
                    outputUri = new Uri(pathProvider.ToAbsolute(jsFile.FilePath), UriKind.Relative);
                    _jsOutput += "    " + outputUri + "\r\n";
                }
            }
        }
        private CrusherManager()
        {
            var crusherConfiguration = CurrentCrusherConfiguration.Current;
            _hashQueryStringKeyName = crusherConfiguration.QuerystringKeyName;
            _cssGroups = crusherConfiguration.CssGroups;
            _jsGroups = crusherConfiguration.JsGroups;

            var retryableFileOpener = new RetryableFileOpener();
            var hasher = new Hasher(retryableFileOpener);
            var retryableFileWriter = new RetryableFileWriter(BufferSize, retryableFileOpener, hasher);
            _pathProvider = new PathProvider();
            var cssAssetsFileHasher = new CssAssetsFileHasher(_hashQueryStringKeyName, hasher, _pathProvider);
            var cssPathRewriter = new CssPathRewriter(cssAssetsFileHasher, _pathProvider);

            _cacheManager = new HttpCacheManager();
            _cssCrusher = new CssCrusher(_cacheManager, _pathProvider, retryableFileOpener, retryableFileWriter, cssPathRewriter);
            _jsCrusher = new JsCrusher(_cacheManager, _pathProvider, retryableFileOpener, retryableFileWriter);

            InitManager();
        }
Beispiel #8
0
        private CrusherManager()
        {
            var crusherConfiguration = CurrentCrusherConfiguration.Current;

            _hashQueryStringKeyName = crusherConfiguration.QuerystringKeyName;
            _cssGroups = crusherConfiguration.CssGroups;
            _jsGroups  = crusherConfiguration.JsGroups;

            var retryableFileOpener = new RetryableFileOpener();
            var hasher = new Hasher(retryableFileOpener);
            var retryableFileWriter = new RetryableFileWriter(BufferSize, retryableFileOpener, hasher);

            _pathProvider = new PathProvider();
            var cssAssetsFileHasher = new CssAssetsFileHasher(_hashQueryStringKeyName, hasher, _pathProvider);
            var cssPathRewriter     = new CssPathRewriter(cssAssetsFileHasher, _pathProvider);

            _cacheManager = new HttpCacheManager();
            _cssCrusher   = new CssCrusher(_cacheManager, _pathProvider, retryableFileOpener, retryableFileWriter, cssPathRewriter);
            _jsCrusher    = new JsCrusher(_cacheManager, _pathProvider, retryableFileOpener, retryableFileWriter);

            InitManager();
        }
Beispiel #9
0
        public StringBuilder ProcessGroups(IPathProvider pathProvider, IJsCrusher jsCrusher, JsGroupElementCollection jsGroups)
        {
            var output = new StringBuilder("Js Files created:\r\n");

            Action <JsGroupToProcess> processJsGroup = ProcessJsGroup;

            var jsGroupsToProcess = jsGroups.Cast <JsGroupElement>()
                                    .Select(group => new JsGroupToProcess
            {
                Crusher      = jsCrusher,
                PathProvider = pathProvider,
                Group        = group,
                Output       = output
            }).ToList();

            if (jsGroupsToProcess.Any())
            {
                ParallelExecute.EachParallel(jsGroupsToProcess, processJsGroup);
            }
            else
            {
                output.AppendFormat("No files to process");
            }
            return(output);
        }
Beispiel #10
0
        private static void CreateCrushedFiles(IPathProvider pathProvider, CssGroupElementCollection cssGroups, JsGroupElementCollection jsGroups, CssCrusher cssCrusher, JsCrusher jsCrusher)
        {
            _cssOutput = "Css Files created:\r\n";
            foreach (CssGroupElement group in cssGroups)
            {
                var files = new List <CssFile>();

                foreach (CssFileElement cssFile in group.Files)
                {
                    var file = new CssFile()
                    {
                        CompressionType = cssFile.CompressionType,
                        FilePath        = cssFile.FilePath
                    };
                    files.Add(file);
                }

                var outputUri = new Uri(pathProvider.ToAbsolute(group.OutputFilePath), UriKind.Relative);
                cssCrusher.AddFiles(outputUri, files, group.AppendHashToCssAsset);

                _cssOutput += outputUri + " (" + group.Name + ")\r\n";
                foreach (var cssFile in files)
                {
                    outputUri   = new Uri(pathProvider.ToAbsolute(cssFile.FilePath), UriKind.Relative);
                    _cssOutput += "    " + outputUri + "\r\n";
                }
            }

            _jsOutput = "Js Files created:\r\n";
            foreach (JsGroupElement group in jsGroups)
            {
                var files = new List <JsFile>();

                foreach (JsFileElement cssFile in group.Files)
                {
                    var file = new JsFile()
                    {
                        CompressionType = cssFile.CompressionType,
                        FilePath        = cssFile.FilePath
                    };
                    files.Add(file);
                }

                var outputUri = new Uri(pathProvider.ToAbsolute(group.OutputFilePath), UriKind.Relative);
                jsCrusher.AddFiles(outputUri, files);

                _jsOutput += outputUri + " (" + group.Name + ")\r\n";
                foreach (var jsFile in files)
                {
                    outputUri  = new Uri(pathProvider.ToAbsolute(jsFile.FilePath), UriKind.Relative);
                    _jsOutput += "    " + outputUri + "\r\n";
                }
            }
        }