示例#1
0
        /// <summary>Initializes a new instance of the NServiceKit.Common.Web.CompressedFileResult class.</summary>
        ///
        /// <exception cref="ArgumentException">Thrown when one or more arguments have unsupported or illegal values.</exception>
        ///
        /// <param name="filePath">       Full pathname of the file.</param>
        /// <param name="compressionType">Type of the compression.</param>
        /// <param name="contentMimeType">Type of the content mime.</param>
        public CompressedFileResult(string filePath, string compressionType, string contentMimeType)
        {
            if (!CompressionTypes.IsValid(compressionType))
            {
                throw new ArgumentException("Must be either 'deflate' or 'gzip'", compressionType);
            }

            this.FilePath = filePath;
            this.Headers  = new Dictionary <string, string> {
                { HttpHeaders.ContentType, contentMimeType },
                { HttpHeaders.ContentEncoding, compressionType },
            };
        }
        /// <summary>Initializes a new instance of the NServiceKit.Common.Web.CompressedResult class.</summary>
        ///
        /// <exception cref="ArgumentException">Thrown when one or more arguments have unsupported or illegal values.</exception>
        ///
        /// <param name="contents">       The contents.</param>
        /// <param name="compressionType">Type of the compression.</param>
        /// <param name="contentMimeType">Type of the content mime.</param>
        public CompressedResult(byte[] contents, string compressionType, string contentMimeType)
        {
            if (!CompressionTypes.IsValid(compressionType))
            {
                throw new ArgumentException("Must be either 'deflate' or 'gzip'", compressionType);
            }

            this.StatusCode  = HttpStatusCode.OK;
            this.ContentType = contentMimeType;

            this.Contents = contents;
            this.Headers  = new Dictionary <string, string> {
                { HttpHeaders.ContentEncoding, compressionType },
            };
        }