Exemplo n.º 1
0
        public ImageflowMiddleware(
            RequestDelegate next,
            IWebHostEnvironment env,
            IEnumerable <ILogger <ImageflowMiddleware> > logger,
            IEnumerable <IMemoryCache> memoryCache,
            IEnumerable <IDistributedCache> distributedCache,
            IEnumerable <ISqliteCache> sqliteCaches,
            IEnumerable <IClassicDiskCache> diskCache,
            IEnumerable <IBlobProvider> blobProviders,
            ImageflowMiddlewareOptions options)
        {
            this.next             = next;
            this.options          = options;
            this.env              = env;
            this.logger           = logger.FirstOrDefault();
            this.memoryCache      = memoryCache.FirstOrDefault();
            this.diskCache        = diskCache.FirstOrDefault();
            this.distributedCache = distributedCache.FirstOrDefault();
            this.sqliteCache      = sqliteCaches.FirstOrDefault();
            var providers   = blobProviders.ToList();
            var mappedPaths = options.MappedPaths.ToList();

            if (options.MapWebRoot)
            {
                if (this.env?.WebRootPath == null)
                {
                    throw new InvalidOperationException("Cannot call MapWebRoot if env.WebRootPath is null");
                }
                mappedPaths.Add(new PathMapping("/", this.env.WebRootPath));
            }

            blobProvider    = new BlobProvider(providers, mappedPaths);
            diagnosticsPage = new DiagnosticsPage(env, this.logger, this.memoryCache, this.distributedCache, this.diskCache, providers);
        }
 public SqliteCacheHostedServiceProxy(ISqliteCache cache)
 {
     this.cache = cache;
 }