示例#1
0
        /// <summary>
        /// Add the images to the cache so that they are monitored for any changes.
        /// </summary>
        /// <param name="imageOutputPath">Sprite image output path.</param>
        /// <param name="outputUri">Sprite image url.</param>
        /// <param name="cssOutputPath">Sprite css output path.</param>
        /// <param name="files">The component images for the sprite.</param>
        public virtual void AddFilesToCache(FileInfo imageOutputPath, Uri outputUri, FileInfo cssOutputPath, IEnumerable <ImageFile> filesToWatch, IEnumerable <ImageFile> files, IEnumerable <Talifun.FileWatcher.IEnhancedFileSystemWatcher> foldersToWatch, IEnumerable <ImageDirectory> directories)
        {
            var fileNames = new List <string>
            {
                imageOutputPath.FullName,
                cssOutputPath.FullName
            };

            fileNames.AddRange(filesToWatch.Select(fileToWatch => new Uri(PathProvider.MapPath(fileToWatch.FilePath)).LocalPath));

            var cssSpriteCacheItem = new CssSpriteCacheItem()
            {
                Files           = files,
                Directories     = directories,
                CssOutputPath   = cssOutputPath,
                ImageOutputPath = imageOutputPath,
                FoldersToWatch  = foldersToWatch,
                FilesToWatch    = filesToWatch,
                SpriteImageUrl  = outputUri
            };

            CacheManager.Insert(
                GetKey(outputUri),
                cssSpriteCacheItem,
                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
        /// <summary>
        /// Add the images to the cache so that they are monitored for any changes.
        /// </summary>
        /// <param name="imageOutputPath">Sprite image output path.</param>
        /// <param name="outputUri">Sprite image url.</param>
        /// <param name="cssOutputPath">Sprite css output path.</param>
        /// <param name="files">The component images for the sprite.</param>
        public virtual void AddFilesToCache(FileInfo imageOutputPath, Uri outputUri, FileInfo cssOutputPath, IEnumerable<ImageFile> filesToWatch, IEnumerable<ImageFile> files, IEnumerable<Talifun.FileWatcher.IEnhancedFileSystemWatcher> foldersToWatch, IEnumerable<ImageDirectory> directories)
        {
            var fileNames = new List<string>
            {
                imageOutputPath.FullName,
                cssOutputPath.FullName
            };
            fileNames.AddRange(filesToWatch.Select(fileToWatch => new Uri(PathProvider.MapPath(fileToWatch.FilePath)).LocalPath));

            var cssSpriteCacheItem = new CssSpriteCacheItem()
            {
                Files = files,
                Directories = directories,
                CssOutputPath = cssOutputPath,
                ImageOutputPath = imageOutputPath,
                FoldersToWatch = foldersToWatch,
                FilesToWatch = filesToWatch,
                SpriteImageUrl = outputUri
            };

            CacheManager.Insert(
                GetKey(outputUri),
                cssSpriteCacheItem,
                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();
            }
        }