示例#1
0
 /// <summary>
 /// Instantiates the <see cref="BitmapMemoryCacheGetProducer"/>.
 /// </summary>
 public BitmapMemoryCacheGetProducer(
     IMemoryCache <ICacheKey, CloseableImage> memoryCache,
     ICacheKeyFactory cacheKeyFactory,
     IProducer <CloseableReference <CloseableImage> > inputProducer) :
     base(memoryCache, cacheKeyFactory, inputProducer)
 {
 }
 /// <summary>
 /// Instantiates the <see cref="ImagePipelineCore"/>.
 /// </summary>
 /// <param name="producerSequenceFactory">
 /// The factory that creates all producer sequences.
 /// </param>
 /// <param name="requestListeners">
 /// The listeners for the image requests.
 /// </param>
 /// <param name="isPrefetchEnabledSupplier">
 /// The supplier for enabling prefetch.
 /// </param>
 /// <param name="bitmapMemoryCache">
 /// The memory cache for CloseableImage.
 /// </param>
 /// <param name="encodedMemoryCache">
 /// The memory cache for IPooledByteBuffer.
 /// </param>
 /// <param name="mainBufferedDiskCache">
 /// The default buffered disk cache.
 /// </param>
 /// <param name="smallImageBufferedDiskCache">
 /// The buffered disk cache used for small images.
 /// </param>
 /// <param name="cacheKeyFactory">
 /// The factory that creates cache keys for the pipeline.
 /// </param>
 /// <param name="threadHandoffProducerQueue">
 /// Move further computation to different thread.
 /// </param>
 /// <param name="flexByteArrayPool">
 /// The memory pool use for BitmapImage conversion.
 /// </param>
 public ImagePipelineCore(
     ProducerSequenceFactory producerSequenceFactory,
     HashSet <IRequestListener> requestListeners,
     ISupplier <bool> isPrefetchEnabledSupplier,
     IMemoryCache <ICacheKey, CloseableImage> bitmapMemoryCache,
     IMemoryCache <ICacheKey, IPooledByteBuffer> encodedMemoryCache,
     BufferedDiskCache mainBufferedDiskCache,
     BufferedDiskCache smallImageBufferedDiskCache,
     ICacheKeyFactory cacheKeyFactory,
     ThreadHandoffProducerQueue threadHandoffProducerQueue,
     FlexByteArrayPool flexByteArrayPool)
 {
     _idCounter = 0;
     _producerSequenceFactory     = producerSequenceFactory;
     _requestListener             = new ForwardingRequestListener(requestListeners);
     _isPrefetchEnabledSupplier   = isPrefetchEnabledSupplier;
     _bitmapMemoryCache           = bitmapMemoryCache;
     _encodedMemoryCache          = encodedMemoryCache;
     _mainBufferedDiskCache       = mainBufferedDiskCache;
     _smallImageBufferedDiskCache = smallImageBufferedDiskCache;
     _cacheKeyFactory             = cacheKeyFactory;
     _threadHandoffProducerQueue  = threadHandoffProducerQueue;
     _flexByteArrayPool           = flexByteArrayPool;
     _handleResultExecutor        = Executors.NewFixedThreadPool(MAX_DATA_SOURCE_SUBSCRIBERS);
 }
 /// <summary>
 /// Instantiates the <see cref="EncodedCacheKeyMultiplexProducer"/>.
 /// </summary>
 public EncodedCacheKeyMultiplexProducer(
     ICacheKeyFactory cacheKeyFactory,
     IProducer <EncodedImage> inputProducer) :
     base(inputProducer)
 {
     _cacheKeyFactory = cacheKeyFactory;
 }
 /// <summary>
 /// Instantiates the <see cref="BitmapMemoryCacheKeyMultiplexProducer"/>.
 /// </summary>
 public BitmapMemoryCacheKeyMultiplexProducer(
     ICacheKeyFactory cacheKeyFactory,
     IProducer <CloseableReference <CloseableImage> > inputProducer) :
     base(inputProducer)
 {
     _cacheKeyFactory = cacheKeyFactory;
 }
 /// <summary>
 /// Instantiates the <see cref="BitmapMemoryCacheProducer"/>.
 /// </summary>
 public BitmapMemoryCacheProducer(
     IMemoryCache <ICacheKey, CloseableImage> memoryCache,
     ICacheKeyFactory cacheKeyFactory,
     IProducer <CloseableReference <CloseableImage> > inputProducer)
 {
     _memoryCache     = memoryCache;
     _cacheKeyFactory = cacheKeyFactory;
     _inputProducer   = inputProducer;
 }
 /// <summary>
 /// Instantiates the <see cref="EncodedMemoryCacheProducer"/>.
 /// </summary>
 public EncodedMemoryCacheProducer(
     IMemoryCache <ICacheKey, IPooledByteBuffer> memoryCache,
     ICacheKeyFactory cacheKeyFactory,
     IProducer <EncodedImage> inputProducer)
 {
     _memoryCache     = memoryCache;
     _cacheKeyFactory = cacheKeyFactory;
     _inputProducer   = inputProducer;
 }
 public TranslationsRepository(
     IContextFactory contextFactory, 
     IAbstractEntitiesFactory entitiesFactory, 
     ICacheFacade cacheFacade, 
     ICacheKeyFactory cacheKeyFactory, 
     ITranslationValidator translationValidator)
     : base(contextFactory, entitiesFactory, cacheFacade, cacheKeyFactory)
 {
     this.translationValidator = translationValidator;
 }
示例#8
0
 protected RepositoryBase(
     IContextFactory contextFactory,
     IAbstractEntitiesFactory entitiesFactory,
     ICacheFacade cacheFacade, 
     ICacheKeyFactory cacheKeyFactory)
 {
     ContextFactory = contextFactory;
     EntitiesFactory = entitiesFactory;
     CacheFacade = cacheFacade;
     CacheKeyFactory = cacheKeyFactory;
 }
        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();
        }
 /// <summary>
 /// Instantiates the <see cref="DiskCacheProducer"/>.
 /// </summary>
 public DiskCacheProducer(
     BufferedDiskCache defaultBufferedDiskCache,
     BufferedDiskCache smallImageBufferedDiskCache,
     ICacheKeyFactory cacheKeyFactory,
     IProducer <EncodedImage> inputProducer,
     int forceSmallCacheThresholdBytes)
 {
     _defaultBufferedDiskCache    = defaultBufferedDiskCache;
     _smallImageBufferedDiskCache = smallImageBufferedDiskCache;
     _cacheKeyFactory             = cacheKeyFactory;
     _inputProducer = inputProducer;
     _forceSmallCacheThresholdBytes = forceSmallCacheThresholdBytes;
     _chooseCacheByImageSize        = (forceSmallCacheThresholdBytes > 0);
 }
 public MongoCollectionResolver([NotNull] ICacheKeyFactory cacheKeyFactory,
                                [NotNull] ICollectionCreator collectionCreator,
                                [NotNull] IMongoDatabaseFactory mongoDatabaseFactory)
 {
     if (cacheKeyFactory == null)
     {
         throw new ArgumentNullException(nameof(cacheKeyFactory));
     }
     if (collectionCreator == null)
     {
         throw new ArgumentNullException(nameof(collectionCreator));
     }
     if (mongoDatabaseFactory == null)
     {
         throw new ArgumentNullException(nameof(mongoDatabaseFactory));
     }
     _cacheKeyFactory      = cacheKeyFactory;
     _collectionCreator    = collectionCreator;
     _mongoDatabaseFactory = mongoDatabaseFactory;
 }
示例#12
0
 public static ICacheKeyFactory GetDefault()
 {
     if (_default == null)
     {
         lock (o)
         {
             if (_default == null)
             {
                 return(_default = new DefaultCacheKeyFactory());
             }
             else
             {
                 return(_default);
             }
         }
     }
     else
     {
         return(_default);
     }
 }
示例#13
0
        /// <summary>
        /// Instantiates the <see cref="ProducerFactory"/>
        /// </summary>
        /// <param name="byteArrayPool">
        /// The IByteArrayPool used by DecodeProducer.
        /// </param>
        /// <param name="imageDecoder">
        /// The image decoder.
        /// </param>
        /// <param name="progressiveJpegConfig">
        /// The progressive Jpeg configuration.
        /// </param>
        /// <param name="downsampleEnabled">
        /// Enabling downsample.
        /// </param>
        /// <param name="resizeAndRotateEnabledForNetwork">
        /// Enabling resize and rotate.
        /// </param>
        /// <param name="executorSupplier">
        /// The supplier for tasks.
        /// </param>
        /// <param name="pooledByteBufferFactory">
        /// The factory that allocates IPooledByteBuffer memory.
        /// </param>
        /// <param name="bitmapMemoryCache">
        /// The memory cache for CloseableImage.
        /// </param>
        /// <param name="encodedMemoryCache">
        /// The memory cache for IPooledByteBuffer.
        /// </param>
        /// <param name="defaultBufferedDiskCache">
        /// The default buffered disk cache.
        /// </param>
        /// <param name="smallImageBufferedDiskCache">
        /// The buffered disk cache used for small images.
        /// </param>
        /// <param name="cacheKeyFactory">
        /// The factory that creates cache keys for the pipeline.
        /// </param>
        /// <param name="platformBitmapFactory">
        /// The bitmap factory used for post process.
        /// </param>
        /// <param name="flexByteArrayPool">
        /// The memory pool used for post process.
        /// </param>
        /// <param name="forceSmallCacheThresholdBytes">
        /// The threshold set for using the small buffered disk cache.
        /// </param>
        public ProducerFactory(
            IByteArrayPool byteArrayPool,
            ImageDecoder imageDecoder,
            IProgressiveJpegConfig progressiveJpegConfig,
            bool downsampleEnabled,
            bool resizeAndRotateEnabledForNetwork,
            IExecutorSupplier executorSupplier,
            IPooledByteBufferFactory pooledByteBufferFactory,
            IMemoryCache <ICacheKey, CloseableImage> bitmapMemoryCache,
            IMemoryCache <ICacheKey, IPooledByteBuffer> encodedMemoryCache,
            BufferedDiskCache defaultBufferedDiskCache,
            BufferedDiskCache smallImageBufferedDiskCache,
            ICacheKeyFactory cacheKeyFactory,
            PlatformBitmapFactory platformBitmapFactory,
            FlexByteArrayPool flexByteArrayPool,
            int forceSmallCacheThresholdBytes)
        {
            _forceSmallCacheThresholdBytes = forceSmallCacheThresholdBytes;

            _byteArrayPool                    = byteArrayPool;
            _imageDecoder                     = imageDecoder;
            _progressiveJpegConfig            = progressiveJpegConfig;
            _downsampleEnabled                = downsampleEnabled;
            _resizeAndRotateEnabledForNetwork = resizeAndRotateEnabledForNetwork;

            _executorSupplier        = executorSupplier;
            _pooledByteBufferFactory = pooledByteBufferFactory;

            _bitmapMemoryCache           = bitmapMemoryCache;
            _encodedMemoryCache          = encodedMemoryCache;
            _defaultBufferedDiskCache    = defaultBufferedDiskCache;
            _smallImageBufferedDiskCache = smallImageBufferedDiskCache;
            _cacheKeyFactory             = cacheKeyFactory;

            _platformBitmapFactory = platformBitmapFactory;
            _flexByteArrayPool     = flexByteArrayPool;
        }
示例#14
0
 public CachedSasService(ISasService sasService, ICache cache, ICacheKeyFactory cacheKeyFactory)
 {
     _sasService      = sasService;
     _cache           = cache;
     _cacheKeyFactory = cacheKeyFactory;
 }
示例#15
0
 public AzureStoragePool(IAzureStorage azureStorage, ICache cache, ICacheKeyFactory cacheKeyFactory)
 {
     _azureStorage    = azureStorage;
     _cache           = cache;
     _cacheKeyFactory = cacheKeyFactory;
 }
示例#16
0
 public CachedCommentService(ICommentService commentService, ICache cache, ICacheKeyFactory cacheKeyFactory)
 {
     _commentService = commentService;
     _cache = cache;
     _cacheKeyFactory = cacheKeyFactory;
 }
 /// <summary>
 /// Sets the cache key factory.
 /// </summary>
 public Builder SetCacheKeyFactory(ICacheKeyFactory cacheKeyFactory)
 {
     CacheKeyFactory = cacheKeyFactory;
     return(this);
 }
示例#18
0
 public CachedTumblrService(ITumblrService tumblrService, ICache cache, ICacheKeyFactory cacheKeyFactory)
 {
     _tumblrService   = tumblrService;
     _cache           = cache;
     _cacheKeyFactory = cacheKeyFactory;
 }