예제 #1
0
        private static void ViewStateTracker(object sender, object e)
        {
            var bounds     = Window.Current.Bounds;
            var windowSize = new Size(bounds.Width, bounds.Height);

            _timer.Interval = CalculateTimerInterval(ViewStateHelper.GetViewState(ApplicationView.GetForCurrentView(), windowSize));
        }
예제 #2
0
        /// <summary>
        /// 重写LoadPageStateFromPersistenceMedium()方法。在这个方法中,解压ViewState。
        /// </summary>
        /// <returns></returns>
        protected override object LoadPageStateFromPersistenceMedium()
        {
            string viewstate = Request.Form["__MYVIEWSTATE"];

            byte[] data             = Convert.FromBase64String(viewstate);
            byte[] uncompressedData =
                ViewStateHelper.Decompress(data);
            string       str       = Convert.ToBase64String(uncompressedData);
            LosFormatter formatter = new LosFormatter();

            return(formatter.Deserialize(str));
        }
예제 #3
0
        /// <summary>
        /// 重写SavePageStateToPersistenceMedium()方法。在这个方法中,压缩ViewState并存储它到隐藏域中。
        /// </summary>
        /// <param name="state"></param>
        protected override void SavePageStateToPersistenceMedium(object state)
        {
            LosFormatter formatter = new LosFormatter();
            StringWriter writer    = new StringWriter();

            formatter.Serialize(writer, state);
            string viewState = writer.ToString();

            byte[] data           = Convert.FromBase64String(viewState);
            byte[] compressedData = ViewStateHelper.Compress(data);
            string str            = Convert.ToBase64String(compressedData);

            ClientScript.RegisterHiddenField("__MYVIEWSTATE", str);
        }
 public string GetCallbackResult()
 {
     if (this.callbackException == null)
     {
         string result;
         try
         {
             Hashtable hashtable = new Hashtable();
             hashtable["Items"] = this.Items;
             hashtable["Cells"] = this.GetCells();
             if (this.EnableViewState)
             {
                 using (StringWriter stringWriter = new StringWriter())
                 {
                     LosFormatter losFormatter = new LosFormatter();
                     losFormatter.Serialize(stringWriter, ViewStateHelper.ToHashtable(this.ViewState));
                     hashtable["VsUpdate"] = stringWriter.ToString();
                 }
             }
             result = SimpleJsonSerializer.Serialize(hashtable);
         }
         catch (Exception ex)
         {
             if (HttpContext.Current.IsDebuggingEnabled)
             {
                 result = "$$$" + ex;
             }
             else
             {
                 result = "$$$" + ex.Message;
             }
         }
         return(result);
     }
     if (HttpContext.Current.IsDebuggingEnabled)
     {
         return("$$$" + this.callbackException);
     }
     return("$$$" + this.callbackException.Message);
 }