public ImageLoaderTask(IMemoryCache <TImageContainer> memoryCache, IDataResolverFactory dataResolverFactory, ITarget <TImageContainer, TImageView> target, TaskParameter parameters, IImageService imageService, Configuration configuration, IMainThreadDispatcher mainThreadDispatcher, bool clearCacheOnOutOfMemory) { _clearCacheOnOutOfMemory = clearCacheOnOutOfMemory; MemoryCache = memoryCache; DataResolverFactory = dataResolverFactory; PlatformTarget = target; ImageService = imageService; Configuration = configuration; MainThreadDispatcher = mainThreadDispatcher; Parameters = parameters; CancellationTokenSource = new CancellationTokenSource(); ImageInformation = new ImageInformation(); CanUseMemoryCache = true; SetKeys(); Target?.SetImageLoadingTask(this); }
public ImageLoaderTask(IMemoryCache <TImageContainer> memoryCache, IDataResolverFactory dataResolverFactory, ITarget <TImageContainer, TImageView> target, TaskParameter parameters, IImageService imageService, Configuration configuration, IMainThreadDispatcher mainThreadDispatcher, bool clearCacheOnOutOfMemory) { _clearCacheOnOutOfMemory = clearCacheOnOutOfMemory; MemoryCache = memoryCache; DataResolverFactory = dataResolverFactory; PlatformTarget = target; ImageService = imageService; Configuration = configuration; MainThreadDispatcher = mainThreadDispatcher; Parameters = parameters; CancellationTokenSource = new CancellationTokenSource(); ImageInformation = new ImageInformation(); CanUseMemoryCache = true; KeyRaw = Parameters.Path; if (Parameters.Source == ImageSource.Stream) { CanUseMemoryCache = false; KeyRaw = string.Concat("Stream_", GetNextStreamIndex()); } if (!string.IsNullOrWhiteSpace(Parameters.CustomCacheKey)) { CanUseMemoryCache = true; KeyRaw = Parameters.CustomCacheKey; } if (string.IsNullOrWhiteSpace(KeyRaw)) { KeyRaw = Guid.NewGuid().ToString("N"); } KeyDownsamplingOnly = string.Empty; if (Parameters.DownSampleSize != null && (Parameters.DownSampleSize.Item1 > 0 || Parameters.DownSampleSize.Item2 > 0)) { KeyDownsamplingOnly = string.Concat(";", Parameters.DownSampleSize.Item1, "x", Parameters.DownSampleSize.Item2); } KeyTransformationsOnly = string.Empty; if (Parameters.Transformations != null && Parameters.Transformations.Count > 0) { KeyTransformationsOnly = string.Concat(string.Join(";", Parameters.Transformations.Select(t => t.Key))); } Key = string.Concat(KeyRaw, KeyDownsamplingOnly, KeyTransformationsOnly); KeyWithoutTransformations = string.Concat(KeyRaw, KeyDownsamplingOnly); if (!string.IsNullOrWhiteSpace(Parameters.LoadingPlaceholderPath)) { if (TransformPlaceholders) { KeyForLoadingPlaceholder = string.Concat(Parameters.LoadingPlaceholderPath, KeyDownsamplingOnly, KeyTransformationsOnly); } else { KeyForLoadingPlaceholder = string.Concat(Parameters.LoadingPlaceholderPath, KeyDownsamplingOnly); } } if (!string.IsNullOrWhiteSpace(Parameters.ErrorPlaceholderPath)) { if (TransformPlaceholders) { KeyForErrorPlaceholder = string.Concat(Parameters.ErrorPlaceholderPath, KeyDownsamplingOnly, KeyTransformationsOnly); } else { KeyForErrorPlaceholder = string.Concat(Parameters.ErrorPlaceholderPath, KeyDownsamplingOnly); } } ImageInformation.SetKey(Key, Parameters.CustomCacheKey); ImageInformation.SetPath(Parameters.Path); Target?.SetImageLoadingTask(this); }
public WrappedDataResolverFactory(IDataResolverFactory factory) { _factory = factory; }