示例#1
0
        public async Task Invoke(IDictionary <string, object> environment)
        {
            IEncoding compression = SelectCompression(environment);

            if (compression == null)
            {
                await _next(environment);

                return;
            }

            ICompressedStorage storage = GetStorage(environment);

            if (storage == null)
            {
                await _next(environment);

                return;
            }

            var context = new StaticCompressionContext(environment, _options, compression, storage);

            context.Attach();
            try
            {
                await _next(environment);

                await context.Complete();
            }
            catch (Exception)
            {
                context.Detach();
                throw;
            }
        }
        public async Task Invoke(IDictionary<string, object> environment)
        {
            IEncoding compression = SelectCompression(environment);
            if (compression == null)
            {
                await _next(environment);
                return;
            }

            ICompressedStorage storage = GetStorage(environment);
            if (storage == null)
            {
                await _next(environment);
                return;
            }

            var context = new StaticCompressionContext(environment, _options, compression, storage);
            context.Attach();
            try
            {
                await _next(environment);
                await context.Complete();
            }
            catch (Exception)
            {
                context.Detach();
                throw;
            }
        }
        public Task Invoke(IDictionary<string, object> environment)
        {
            IEncoding compression = SelectCompression(environment);
            if (compression == null)
            {
                return _next(environment);
            }

            ICompressedStorage storage = GetStorage(environment);
            if (storage == null)
            {
                return _next(environment);
            }

            var context = new StaticCompressionContext(environment, _options, compression, storage);
            context.Attach();
            return _next(environment)
                .Then((Func<Task>)context.Complete)
                .Catch(context.Complete);
        }
示例#4
0
        public Task Invoke(IDictionary <string, object> environment)
        {
            IEncoding compression = SelectCompression(environment);

            if (compression == null)
            {
                return(_next(environment));
            }

            ICompressedStorage storage = GetStorage(environment);

            if (storage == null)
            {
                return(_next(environment));
            }

            var context = new StaticCompressionContext(environment, _options, compression, storage);

            context.Attach();
            return(_next(environment)
                   .Then((Func <Task>)context.Complete)
                   .Catch(context.Complete));
        }