private ImagePipelineConfig(Builder builder) { _animatedImageFactory = builder.AnimatedImageFactory; _bitmapMemoryCacheParamsSupplier = builder.BitmapMemoryCacheParamsSupplier ?? new DefaultBitmapMemoryCacheParamsSupplier(); _bitmapConfig = builder.BitmapConfig == default(BitmapPixelFormat) ? BitmapPixelFormat.Bgra8 : builder.BitmapConfig; _cacheKeyFactory = builder.CacheKeyFactory ?? DefaultCacheKeyFactory.Instance; _decodeMemoryFileEnabled = builder.IsDecodeMemoryFileEnabled; _fileCacheFactory = builder.FileCacheFactory ?? new DiskStorageCacheFactory(new DynamicDefaultDiskStorageFactory()); _downsampleEnabled = builder.IsDownsampleEnabled; _encodedMemoryCacheParamsSupplier = builder.EncodedMemoryCacheParamsSupplier ?? new DefaultEncodedMemoryCacheParamsSupplier(); _imageCacheStatsTracker = builder.ImageCacheStatsTracker ?? NoOpImageCacheStatsTracker.Instance; _imageDecoder = builder.ImageDecoder; _isPrefetchEnabledSupplier = builder.IsPrefetchEnabledSupplier ?? new SupplierImpl <bool>( () => { return(true); }); _mainDiskCacheConfig = builder.MainDiskCacheConfig ?? GetDefaultMainDiskCacheConfig(); _memoryTrimmableRegistry = builder.MemoryTrimmableRegistry ?? NoOpMemoryTrimmableRegistry.Instance; _networkFetcher = builder.NetworkFetcher ?? new HttpUrlConnectionNetworkFetcher(); _platformBitmapFactory = builder.PlatformBitmapFactory; _poolFactory = builder.PoolFactory ?? new PoolFactory(PoolConfig.NewBuilder().Build()); _progressiveJpegConfig = builder.ProgressiveJpegConfig == default(IProgressiveJpegConfig) ? new SimpleProgressiveJpegConfig() : builder.ProgressiveJpegConfig; _requestListeners = builder.RequestListeners ?? new HashSet <IRequestListener>(); _resizeAndRotateEnabledForNetwork = builder.ResizeAndRotateEnabledForNetwork; _smallImageDiskCacheConfig = builder.SmallImageDiskCacheConfig ?? _mainDiskCacheConfig; // Below this comment can't be built in alphabetical order, because of dependencies int numCpuBoundThreads = _poolFactory.FlexByteArrayPoolMaxNumThreads; _executorSupplier = builder.ExecutorSupplier ?? new DefaultExecutorSupplier(numCpuBoundThreads); _imagePipelineExperiments = builder.Experiment.Build(); }
public void Initialize() { // Initializes the IFileCache _fileCacheFactory = new DiskStorageCacheFactory(new DynamicDefaultDiskStorageFactory()); _fileCache = _fileCacheFactory.Get(DiskCacheConfig.NewBuilder().Build()); // Initializes the IPooledByteBufferFactory and PooledByteStreams _poolFactory = new PoolFactory(PoolConfig.NewBuilder().Build()); _byteBufferFactory = _poolFactory.PooledByteBufferFactory; _pooledByteStreams = _poolFactory.PooledByteStreams; // Initializes the IPooledByteBuffer from an image var file = StorageFile.GetFileFromApplicationUriAsync( new Uri("ms-appx:///Assets/SplashScreen.scale-200.png")).GetAwaiter().GetResult(); using (var stream = file.OpenReadAsync().GetAwaiter().GetResult()) { _pooledByteBuffer = _byteBufferFactory.NewByteBuffer( ByteStreams.ToByteArray(stream.AsStream())); } _closeableReference = CloseableReference <IPooledByteBuffer> .of(_pooledByteBuffer); _encodedImage = new EncodedImage(_closeableReference); _stagingArea = StagingArea.Instance; _imageCacheStatsTracker = NoOpImageCacheStatsTracker.Instance; // Initializes the cache keys IList <ICacheKey> keys = new List <ICacheKey>(); keys.Add(new SimpleCacheKey("http://test.uri")); keys.Add(new SimpleCacheKey("http://tyrone.uri")); keys.Add(new SimpleCacheKey("http://ian.uri")); _cacheKey = new MultiCacheKey(keys); // Initializes the executors _isCancelled = new AtomicBoolean(false); _readPriorityExecutor = Executors.NewFixedThreadPool(1); _writePriorityExecutor = Executors.NewFixedThreadPool(1); // Initializes the disk cache _bufferedDiskCache = new BufferedDiskCache( _fileCache, _byteBufferFactory, _pooledByteStreams, _readPriorityExecutor, _writePriorityExecutor, _imageCacheStatsTracker); }
public OnlineVersionHelper(UpdateInformationProvider updateInformationProvider, ITempFolderProvider tempFolderProvider, IVersionHelper versionHelper, IUpdateChangeParser changeParser, IFileCacheFactory fileCacheFactory, IDownloader downloader, ICurrentSettings <ApplicationSettings> applicationSettingsProvider) { _updateInformationProvider = updateInformationProvider; _tempFolderProvider = tempFolderProvider; _versionHelper = versionHelper; _changeParser = changeParser; _fileCacheFactory = fileCacheFactory; _downloader = downloader; _applicationSettingsProvider = applicationSettingsProvider; if (_applicationSettingsProvider != null) { _fileCache = GetFileCache(); _applicationSettingsProvider.SettingsChanged += ApplicationSettingsProviderOnSettingsChanged; } _onlineVersion = new ApplicationVersion(new System.Version(0, 0, 0, 0), "", "", new List <Release>()); }
public RssFeedViewModel(ICommandLocator commandLocator, ICurrentSettings <Conversion.Settings.RssFeed> rssFeedSettingsProvider, IGpoSettings gpoSettings, ITranslationUpdater translationUpdater, IWelcomeSettingsHelper welcomeSettingsHelper, IRssService rssService, IFileCacheFactory fileCacheFactory, ITempFolderProvider tempFolderProvider) : base(translationUpdater) { _rssFeedSettingsProvider = rssFeedSettingsProvider; _gpoSettings = gpoSettings; _rssService = rssService; _fileCacheFactory = fileCacheFactory; _tempFolderProvider = tempFolderProvider; _feedItems = new List <FeedItem>(); _fileCache = GetFileCache(); ShowWelcome = welcomeSettingsHelper.CheckIfRequiredAndSetCurrentVersion(); //Because the CheckIfRequiredAndSetCurrentVersion() sets the version in the registry, RaisePropertyChanged(nameof(ShowWelcome)); // ShowWelcome has to be set here in the ctor and not directly in the property UrlOpenCommand = commandLocator.GetCommand <UrlOpenCommand>(); ShowRssFeedCommand = new DelegateCommand(ShowRssFeed); ShowWelcomeWindow(); }
/// <summary> /// Sets the file cache factory. /// </summary> public Builder SetFileCacheFactory(IFileCacheFactory fileCacheFactory) { FileCacheFactory = fileCacheFactory; return(this); }