예제 #1
0
        public override void Write(Byte[] buffer, int offset, int count)
        {
            Byte[] data = SevenZipSharpHelper.Compress(buffer);
            String txt  = Convert.ToBase64String(data, Base64FormattingOptions.InsertLineBreaks);

            data = Encoding.UTF8.GetBytes(txt);
            deflateStream.Write(data, 0, data.Length);
        }
예제 #2
0
 /// <summary>
 /// 保存页面状态
 /// </summary>
 public override void Save()
 {
     if (ViewState != null || ControlState != null)
     {
         Pair data = new Pair(ViewState, ControlState);
         //序列化,压缩
         String strbase64 = new ObjectStateFormatter().Serialize(data);
         String strzip    = SevenZipSharpHelper.Compress(strbase64);
         //把页面状态注册到页面上
         Page.ClientScript.RegisterHiddenField(STATEKEY, strzip);
     }
 }
예제 #3
0
        public override void OnActionExecuted(HttpActionExecutedContext context)
        {
            HttpResponseMessage Response = context.Response;
            HttpContent         content  = Response.Content;

            Byte[] buffer = content == null ? new Byte[0] : content.ReadAsByteArrayAsync().Result;
            buffer = SevenZipSharpHelper.Compress(buffer);

            Response.Content = new ByteArrayContent(buffer);
            //Response.Content.Headers.Add("Content-encoding", "7z");
            Response.Content.Headers.Remove("Content-Type");
            Response.Content.Headers.Add("Content-Type", "application/octet-stream");
            base.OnActionExecuted(context);
        }
예제 #4
0
 public override void Write(Byte[] buffer, int offset, int count)
 {
     Byte[] data = SevenZipSharpHelper.Compress(buffer);
     deflateStream.Write(data, 0, data.Length);
 }