Esempio n. 1
0
        /// <summary>
        /// Add the css files to the cache so that they are monitored for any changes.
        /// </summary>
        /// <param name="outputUri">The path for the crushed css file.</param>
        /// <param name="cssFiles">The css files to be crushed.</param>
        /// <param name="cssAssetFilePaths">The css asset files referenced by the css files.</param>
        public virtual void AddFilesToCache(Uri outputUri, IEnumerable<CssFile> cssFiles, IEnumerable<FileInfo> cssAssetFilePaths)
        {
            var fileNames = new List<string>
                                {
                                    PathProvider.MapPath(outputUri)
                                };
            fileNames.AddRange(cssFiles.Select(cssFile => PathProvider.MapPath(cssFile.FilePath)));
            fileNames.AddRange(cssAssetFilePaths.Select(cssAssetFilePath => cssAssetFilePath.FullName));

            var cssCacheItem = new CssCacheItem()
                                   {
                                       OutputUri = outputUri,
                                       CssFiles = cssFiles,
                                       CssAssetFilePaths = cssAssetFilePaths
                                   };

            HttpRuntime.Cache.Insert(
                GetKey(outputUri),
                cssCacheItem,
                new CacheDependency(fileNames.ToArray(), System.DateTime.Now),
                Cache.NoAbsoluteExpiration,
                Cache.NoSlidingExpiration,
                CacheItemPriority.High,
                FileRemoved);
        }
Esempio n. 2
0
        /// <summary>
        /// Add the css files to the cache so that they are monitored for any changes.
        /// </summary>
        /// <param name="outputUri">The path for the crushed css file.</param>
        /// <param name="cssFiles">The css files to be crushed.</param>
        /// <param name="cssAssetFilePaths">The css asset files referenced by the css files.</param>
        public virtual void AddFilesToCache(Uri outputUri, IEnumerable <CssFile> cssFiles, IEnumerable <FileInfo> cssAssetFilePaths)
        {
            var fileNames = new List <string>
            {
                PathProvider.MapPath(outputUri)
            };

            fileNames.AddRange(cssFiles.Select(cssFile => PathProvider.MapPath(cssFile.FilePath)));
            fileNames.AddRange(cssAssetFilePaths.Select(cssAssetFilePath => cssAssetFilePath.FullName));

            var cssCacheItem = new CssCacheItem()
            {
                OutputUri         = outputUri,
                CssFiles          = cssFiles,
                CssAssetFilePaths = cssAssetFilePaths
            };

            CacheManager.Insert(
                GetKey(outputUri),
                cssCacheItem,
                new CacheDependency(fileNames.ToArray(), System.DateTime.Now),
                Cache.NoAbsoluteExpiration,
                Cache.NoSlidingExpiration,
                CacheItemPriority.High,
                FileRemoved);
        }
Esempio n. 3
0
        /// <summary>
        /// Add the css files to the cache so that they are monitored for any changes.
        /// </summary>
        /// <param name="outputUri">The path for the crushed css file.</param>
        /// <param name="filesToWatch">Files that are crushed.</param>
        /// <param name="assetFilesToWatch">The css asset files referenced by the css files.</param>
        /// <param name="files">The css files to be crushed.</param>
        /// <param name="foldersToWatch"> </param>
        /// <param name="directories">The css directories to be crushed. </param>
        public virtual void AddGroupToCache(Uri outputUri, IEnumerable <CssFileToWatch> filesToWatch, IEnumerable <FileInfo> assetFilesToWatch, IEnumerable <CssFile> files, IEnumerable <Talifun.FileWatcher.IEnhancedFileSystemWatcher> foldersToWatch, IEnumerable <CssDirectory> directories)
        {
            var fileNames = new List <string>
            {
                PathProvider.MapPath(outputUri)
            };

            fileNames.AddRange(filesToWatch.Select(cssFile => new Uri(PathProvider.MapPath(cssFile.FilePath)).LocalPath));
            fileNames.AddRange(assetFilesToWatch.Select(cssAssetFilePath => cssAssetFilePath.FullName));

            var cacheItem = new CssCacheItem()
            {
                OutputUri         = outputUri,
                AssetFilesToWatch = assetFilesToWatch,
                FilesToWatch      = filesToWatch,
                Files             = files,
                FoldersToWatch    = foldersToWatch,
                Directories       = directories,
            };

            CacheManager.Insert(
                GetKey(outputUri),
                cacheItem,
                new CacheDependency(fileNames.ToArray(), System.DateTime.Now),
                Cache.NoAbsoluteExpiration,
                Cache.NoSlidingExpiration,
                CacheItemPriority.High,
                FileRemoved);

            foreach (var enhancedFileSystemWatcher in foldersToWatch)
            {
                enhancedFileSystemWatcher.FileActivityFinishedEvent += OnFileActivityFinishedEvent;
                enhancedFileSystemWatcher.UserState = outputUri;
                enhancedFileSystemWatcher.Start();
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Add the css files to the cache so that they are monitored for any changes.
        /// </summary>
        /// <param name="outputUri">The path for the crushed css file.</param>
        /// <param name="filesToWatch">Files that are crushed.</param>
        /// <param name="assetFilesToWatch">The css asset files referenced by the css files.</param>
        /// <param name="files">The css files to be crushed.</param>
        /// <param name="foldersToWatch"> </param>
        /// <param name="directories">The css directories to be crushed. </param>
        public virtual void AddGroupToCache(Uri outputUri, IEnumerable<CssFileToWatch> filesToWatch, IEnumerable<FileInfo> assetFilesToWatch, IEnumerable<CssFile> files, IEnumerable<Talifun.FileWatcher.IEnhancedFileSystemWatcher> foldersToWatch, IEnumerable<CssDirectory> directories)
        {
            var fileNames = new List<string>
            {
                PathProvider.MapPath(outputUri)
            };
            fileNames.AddRange(filesToWatch.Select(cssFile => new Uri(PathProvider.MapPath(cssFile.FilePath)).LocalPath));
            fileNames.AddRange(assetFilesToWatch.Select(cssAssetFilePath => cssAssetFilePath.FullName));

            var cacheItem = new CssCacheItem()
            {
                OutputUri = outputUri,
                AssetFilesToWatch = assetFilesToWatch,
                FilesToWatch = filesToWatch,
                Files = files,
                FoldersToWatch = foldersToWatch,
                Directories = directories,
            };

            CacheManager.Insert(
                GetKey(outputUri),
                cacheItem,
                new CacheDependency(fileNames.ToArray(), System.DateTime.Now),
                Cache.NoAbsoluteExpiration,
                Cache.NoSlidingExpiration,
                CacheItemPriority.High,
                FileRemoved);

            foreach (var enhancedFileSystemWatcher in foldersToWatch)
            {
                enhancedFileSystemWatcher.FileActivityFinishedEvent += OnFileActivityFinishedEvent;
                enhancedFileSystemWatcher.UserState = outputUri;
                enhancedFileSystemWatcher.Start();
            }
        }