コード例 #1
0
ファイル: CssCrusher.cs プロジェクト: kouweizhong/talifun-web
        /// <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();
            }
        }
コード例 #2
0
ファイル: CssCrusher.cs プロジェクト: atifaziz/talifun-web
        /// <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();
            }
        }