public GoogleMapsClient(string apiKey, string signingKey, IJsonFactory <MetadataTypeT> metadataDecoder, IJsonFactory <GeocodingResponse> geocodingDecoder, CachingStrategy cache) { this.apiKey = apiKey ?? throw new ArgumentNullException(nameof(apiKey)); this.signingKey = signingKey ?? throw new ArgumentNullException(nameof(signingKey)); this.metadataDecoder = metadataDecoder ?? throw new ArgumentNullException(nameof(metadataDecoder)); this.geocodingDecoder = geocodingDecoder ?? throw new ArgumentNullException(nameof(geocodingDecoder)); this.cache = cache ?? throw new ArgumentNullException(nameof(cache)); foreach (var(fileRef, metadata) in cache.Get(metadataDecoder)) { if (metadata.Location != null) { _ = Cache(metadata); var imageRef = metadata.Pano_ID + MediaType.Image.Jpeg; if (cache.IsCached(imageRef)) { knownImages.Add(metadata.Pano_ID); } } else { _ = cache.Delete(fileRef); } } foreach (var fileRef in cache.GetContentReferences(MediaType.Image.Jpeg)) { knownImages.Add(fileRef.CacheID); } knownImages.Sort(); }
/// <summary> /// Before populating a target object, generates mappings or loads from cache /// </summary> /// <param name="target"></param> /// <param name="source"></param> protected virtual void OnBeforePopulate(TTarget target, TSource source) { if (CachingStrategy is NullCachingStrategy && !MappingStrategy.GeneratedMappings) { MappingStrategy.GetMappings(source, typeof(TTarget), MatchingStrategy, AutoMapUnspecifiedTargets); } else { var cacheKey = GetCacheKey(); var cachedMappings = CachingStrategy.Get(cacheKey) as List <IPropertyMapping>; if (cachedMappings == null) { cachedMappings = MappingStrategy.GetMappings(source, typeof(TTarget), MatchingStrategy, AutoMapUnspecifiedTargets); CachingStrategy.Set(cacheKey, cachedMappings); } else { MappingStrategy.SetMappings(cachedMappings); } } }
public TItem Get(string key) { return(_cachingStrategy.Get(key)); }