예제 #1
0
        public Task Complete()
        {
            InterceptMode interceptMode = Intercept();

            Detach();

            switch (interceptMode)
            {
            case InterceptMode.DoingNothing:
                return(TaskHelpers.Completed());

            case InterceptMode.CompressingToStorage:
                _compressingStream.Close();
                _compressedItem         = _storage.Commit(_compressedItemBuilder);
                _response.ContentLength = _compressedItem.CompressedLength;
                _response.ETag          = _compressedETag;
                _response.Headers.Set("Content-Encoding", _encoding.Name);
                if (_compressedItem.PhysicalPath != null && _originalSendFileAsyncDelegate != null)
                {
                    return(_originalSendFileAsyncDelegate.Invoke(_compressedItem.PhysicalPath, 0, _compressedItem.CompressedLength, _request.CallCancelled));
                }
                else
                {
                    // TODO: stream copy operation
                }
                return(TaskHelpers.Completed());

            case InterceptMode.SentFromStorage:
                _response.ETag = _compressedETag;
                _response.Headers.Set("Content-Encoding", _encoding.Name);
                if (_compressedItem != null)
                {
                    _response.ContentLength = _compressedItem.CompressedLength;
                    if (_compressedItem.PhysicalPath != null && _originalSendFileAsyncDelegate != null)
                    {
                        return(_originalSendFileAsyncDelegate.Invoke(_compressedItem.PhysicalPath, 0, _compressedItem.CompressedLength, _request.CallCancelled));
                    }
                    else
                    {
                        // TODO: stream copy operation
                    }
                }
                return(TaskHelpers.Completed());
            }

            throw new NotImplementedException();
        }
예제 #2
0
 protected Aspect(InterceptMode mode = InterceptMode.Before)
 {
     Mode     = mode;
     Category = CommonCategories.Unknown;
 }
예제 #3
0
 protected Aspect(Enum category, InterceptMode mode = InterceptMode.Before)
 {
     InstanceId = Guid.NewGuid();
     Mode       = mode;
     Category   = category;
 }