public override void RemoveFromCache(Dependency dependency)
 {
     foreach (var dictionaryEntry in Cache.Cast<DictionaryEntry>().Where(de => de.Value is InProcCacheEntry))
     {
         InProcCacheEntry cacheEntry = (InProcCacheEntry) dictionaryEntry.Value;
         if (cacheEntry.Dependencies.Contains(dependency))
             Cache.Remove((string) dictionaryEntry.Key);
     }
 }
 public override void AddToCache(string cacheKey, CompositionImage compositionImage, Dependency[] dependencies)
 {
     InProcCacheEntry cacheEntry = new InProcCacheEntry
     {
         CompositionImage = compositionImage,
         Dependencies = dependencies
     };
     Cache.Insert(cacheKey, cacheEntry);
 }
 public override void AddToCache(string cacheKey, GeneratedImage generatedImage, Dependency[] dependencies)
 {
     InProcCacheEntry cacheEntry = new InProcCacheEntry
     {
         GeneratedImage = generatedImage,
         Dependencies = dependencies
     };
     Cache.Insert(cacheKey, cacheEntry);
 }
Esempio n. 4
0
        public override void AddToCache(string cacheKey, GeneratedImage generatedImage, Dependency[] dependencies)
        {
            EnsureDocument();

            // Save image to disk.
            SaveImageToDiskCache(cacheKey, generatedImage);

            lock (_doc)
            {
                // Double-check that item hasn't been added to cache since we checked.
                if (ExistsInCache(cacheKey))
                    return;

                var itemElement = new XElement("item",
                    new XAttribute("id", cacheKey),
                    new XAttribute("isImagePresent", generatedImage.Properties.IsImagePresent),
                    new XAttribute("format", generatedImage.Properties.Format),
                    new XAttribute("colourDepth", generatedImage.Properties.ColourDepth));
                if (generatedImage.Properties.Width != null)
                    itemElement.Add(new XAttribute("width", generatedImage.Properties.Width.Value));
                if (generatedImage.Properties.Height != null)
                    itemElement.Add(new XAttribute("height", generatedImage.Properties.Height.Value));
                if (generatedImage.Properties.JpegCompressionLevel != null)
                    itemElement.Add(new XAttribute("jpegCompressionLevel", generatedImage.Properties.JpegCompressionLevel.Value));

                XElement dependenciesElement = new XElement("dependencies");
                itemElement.Add(dependenciesElement);

                foreach (var dependency in dependencies)
                    dependenciesElement.Add(new XElement("dependency",
                        new XAttribute("text1", dependency.Text1),
                        new XAttribute("text2", dependency.Text2),
                        new XAttribute("text3", dependency.Text3),
                        new XAttribute("text4", dependency.Text4)));

                _doc.Root.Add(itemElement);
                _doc.Save(_docPath);
            }
        }
 private static void RemoveByDependency(Dependency dependency)
 {
     Provider.RemoveFromCache(dependency);
 }
 internal static void Add(string cacheKey, GeneratedImage generatedImage, Dependency[] dependencies)
 {
     Provider.AddToCache(cacheKey, generatedImage, dependencies);
 }
 public abstract void RemoveFromCache(Dependency dependency);
 public abstract void AddToCache(string cacheKey, GeneratedImage generatedImage, Dependency[] dependencies);
 public override void PopulateDependencies(List<Dependency> dependencies)
 {
     Dependency dependency = new Dependency();
     dependency.Text1 = ConnectionStringName;
     dependency.Text2 = TableName;
     dependency.Text3 = (PrimaryKeyValues != null) ? string.Join(",", PrimaryKeyValues) : string.Empty;
     dependencies.Add(dependency);
 }
Esempio n. 10
0
        public override void RemoveFromCache(Dependency dependency)
        {
            EnsureDocument();

            lock (_doc)
            {
                Func<XElement, bool> attributeMatcher = d => d.Attribute("text1").Value == dependency.Text1
                    && d.Attribute("text2").Value == dependency.Text2
                        && d.Attribute("text3").Value == dependency.Text3
                            && d.Attribute("text4").Value == dependency.Text4;

                var items = _doc.Root.Elements().Where(e => e.Element("dependencies").Elements().Any(attributeMatcher)).ToList();
                foreach (XElement itemElement in items)
                {
                    string cacheKey;
                    ImageProperties imageProperties;
                    GetImageProperties(itemElement, out cacheKey, out imageProperties);
                    DeleteImageFromDiskCache(cacheKey, imageProperties, HttpContext.Current);
                    itemElement.Remove();
                }

                _doc.Save(_docPath);
            }
        }
 internal static void Add(string cacheKey, CompositionImage compositionImage, Dependency[] dependencies)
 {
     Provider.AddToCache(cacheKey, compositionImage, dependencies);
 }
Esempio n. 12
0
 private static void RemoveByDependency(Dependency dependency)
 {
     Provider.RemoveFromCache(dependency);
 }
 public abstract void AddToCache(string cacheKey, CompositionImage compositionImage, Dependency[] dependencies);