當前位置: 首頁>>代碼示例>>C#>>正文


C# UI.LosFormatter類代碼示例

本文整理匯總了C#中System.Web.UI.LosFormatter的典型用法代碼示例。如果您正苦於以下問題:C# LosFormatter類的具體用法?C# LosFormatter怎麽用?C# LosFormatter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


LosFormatter類屬於System.Web.UI命名空間,在下文中一共展示了LosFormatter類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Ctor_BoolByteArray

		public void Ctor_BoolByteArray ()
		{
			LosFormatter lf1 = new LosFormatter (false, (byte []) null);
			string expected = NoKeyRoundTrip (lf1, "false, null");

			LosFormatter lf2 = new LosFormatter (true, (byte []) null);
			Assert.AreEqual (expected, NoKeyRoundTrip (lf2, "true, null"), "2");

			LosFormatter lf3 = new LosFormatter (false, Empty);
			Assert.AreEqual (expected, NoKeyRoundTrip (lf3, "false, empty"), "3");

			// an empty key is still a key - a signature is appended
			LosFormatter lf4 = new LosFormatter (true, Empty);
			string signed = NoKeyRoundTrip (lf4, "true, empty");
			Assert.AreNotEqual (expected, signed, "4");

			byte [] data = Convert.FromBase64String (expected);
			byte [] signed_data = Convert.FromBase64String (signed);
			Assert.IsTrue (BitConverter.ToString (signed_data).StartsWith (BitConverter.ToString (data)), "4 / same data");
#if NET_4_0
			// 32 bytes == 256 bits -> match HMACSHA256 as default
			Assert.AreEqual (32, signed_data.Length - data.Length, "signature length");
#else
			// 20 bytes == 160 bits -> match HMACSHA1 as default
			Assert.AreEqual (20, signed_data.Length - data.Length, "signature length");
#endif
		}
開發者ID:nobled,項目名稱:mono,代碼行數:27,代碼來源:LosFormatterTest.cs

示例2: LoadPageStateFromCompressedViewState

 protected object LoadPageStateFromCompressedViewState()
 {
     string viewState = Request.Form["__VSTATE"];
     byte[] bytes = Convert.FromBase64String(viewState);
     bytes = IntegrationWebSiteMvc.Classes.Compressor.Decompress(bytes);
     LosFormatter formatter = new LosFormatter();
     return formatter.Deserialize(Convert.ToBase64String(bytes));
 }
開發者ID:bedford603067,項目名稱:Augment,代碼行數:8,代碼來源:AssetAttributes.aspx.cs

示例3: Load

 public override void Load()
 {
     IPersistViewState state = Ra.Brix.Data.Internal.Adapter.Instance as IPersistViewState;
     LosFormatter formatter = new LosFormatter();
     Pair pair = formatter.Deserialize(state.Load(_session.ToString(), Page.Request.Url.ToString())) as Pair;
     ViewState = pair.First;
     ControlState = pair.Second;
 }
開發者ID:greaterwinner,項目名稱:ra-brix,代碼行數:8,代碼來源:RaBrixPageStatePersister.cs

示例4: Load

 public override void Load()
 {
     string viewStateString = Page.Request["__AJAXVIEWSTATE"];
     viewStateString = viewStateString.Replace(",", "").Replace(" ", "");
     LosFormatter los = new LosFormatter();
     Pair pair = (Pair)los.Deserialize(viewStateString);
     base.ViewState = pair.First;
     base.ControlState = pair.Second;
 }
開發者ID:Houfeng,項目名稱:AjaxEngine,代碼行數:9,代碼來源:HiddenFieldPageStatePersister.cs

示例5: LoadPageStateFromPersistenceMedium

        protected override object LoadPageStateFromPersistenceMedium()
        {
            string viewState = Request.Form["__VSTATE"];
            byte[] bytes = Convert.FromBase64String(viewState);
            LosFormatter formatter = new LosFormatter();

            bytes = bytes.Decompress();

            return formatter.Deserialize(Convert.ToBase64String(bytes));
        }
開發者ID:gabla5,項目名稱:SO-Answers,代碼行數:10,代碼來源:CompressPageViewState.aspx.cs

示例6: SavePageStateToCompressedViewState

 protected void SavePageStateToCompressedViewState(object viewState)
 {
     LosFormatter formatter = new LosFormatter();
     System.IO.StringWriter writer = new System.IO.StringWriter();
     formatter.Serialize(writer, viewState);
     string viewStateString = writer.ToString();
     byte[] bytes = Convert.FromBase64String(viewStateString);
     bytes = IntegrationWebSiteMvc.Classes.Compressor.Compress(bytes);
     ClientScript.RegisterHiddenField("__VSTATE", Convert.ToBase64String(bytes));
 }
開發者ID:bedford603067,項目名稱:Augment,代碼行數:10,代碼來源:AssetAttributes.aspx.cs

示例7: GetCacheKey

        /// <summary>
        /// Creates a unique key which describes the current object. This key is used
        /// by <see cref="SoundInTheory.DynamicImage.Caching.DynamicImageCacheManager" />
        /// to cache dynamically generated images.
        /// </summary>
        /// <returns>A unique key which describes the current object.</returns>
        public string GetCacheKey()
        {
            object allViewState = SaveViewState(true);

            LosFormatter formatter = new LosFormatter();
            StringWriter output = new StringWriter();
            formatter.Serialize(output, allViewState);

            return output.ToString();
        }
開發者ID:dbre2,項目名稱:dynamic-image,代碼行數:16,代碼來源:StateManagedObject.cs

示例8: Deserialize_Stream_NonSeekable

		[Test] // bug #411115
		public void Deserialize_Stream_NonSeekable ()
		{
			string s1 = "Hello world";
			NonSeekableStream ns = new NonSeekableStream ();
			LosFormatter lf = new LosFormatter ();
			lf.Serialize (ns, s1);
			ns.Reset ();
			string s2 = lf.Deserialize (ns) as string;
			Assert.AreEqual (s1, s2);
		}
開發者ID:calumjiao,項目名稱:Mono-Class-Libraries,代碼行數:11,代碼來源:LosFormatterTest.cs

示例9: LoadPageStateFromPersistenceMedium

        protected override object LoadPageStateFromPersistenceMedium()
        {
            string vState = this.Request.Form["__VSTATE"];
            byte[] bytes = System.Convert.FromBase64String( vState );

            bytes = this.Decompress( bytes );

            LosFormatter format = new LosFormatter();
            return format.Deserialize( System.Convert.ToBase64String( bytes ) );
        }
開發者ID:popovegor,項目名稱:gt,代碼行數:10,代碼來源:GTCommonWebPage.cs

示例10: LosFormatter

		private LosFormatter  _formatter;// = new LosFormatter();
		protected override void SavePageStateToPersistenceMedium(object viewState)
		{
			_formatter = new LosFormatter();

			StringWriter sw = new StringWriter();
			_formatter.Serialize(sw, viewState);
			ComDePress cmp = new ComDePress();
			string outStr = cmp.Compress(sw.ToString());
			Page.RegisterHiddenField("__COMPRESSEDVIEWSTATE",outStr);
		}
開發者ID:alexan1,項目名稱:marketweb,代碼行數:11,代碼來源:CompressedVSBasePage.cs

示例11: LoadPageStateFromPersistenceMedium

		protected override object LoadPageStateFromPersistenceMedium()
		{
			_formatter = new LosFormatter();
			object o;

			string vsString = Request.Form["__COMPRESSEDVIEWSTATE"];
			string outStr = new ComDePress().DeCompress(vsString);
			o = _formatter.Deserialize(outStr);
			return o;
		}
開發者ID:alexan1,項目名稱:marketweb,代碼行數:10,代碼來源:CompressedVSBasePage.cs

示例12: Save

 public override void Save()
 {
     IPersistViewState state = Ra.Brix.Data.Internal.Adapter.Instance as IPersistViewState;
     LosFormatter formatter = new LosFormatter();
     StringBuilder builder = new StringBuilder();
     using (StringWriter writer = new StringWriter(builder))
     {
         formatter.Serialize(writer, new Pair(ViewState, ControlState));
     }
     state.Save(_session.ToString(), Page.Request.Url.ToString(), builder.ToString());
 }
開發者ID:greaterwinner,項目名稱:ra-brix,代碼行數:11,代碼來源:RaBrixPageStatePersister.cs

示例13: Serialize

		[Test] // bug #324526
		public void Serialize ()
		{
			string s = "Hello world";
			LosFormatter lf = new LosFormatter ();
			StringWriter sw = new StringWriter ();
			lf.Serialize (sw, s);
			string s1 = sw.ToString ();
			Assert.IsNotNull (s1, "#1");
			string s2 = lf.Deserialize (s1) as string;
			Assert.IsNotNull (s2, "#2");
			Assert.AreEqual (s, s2, "#3");
		}
開發者ID:calumjiao,項目名稱:Mono-Class-Libraries,代碼行數:13,代碼來源:LosFormatterTest.cs

示例14: Load

		public override void Load()
		{
			string id = _session.ToString() + "|" + Page.Request.Url.ToString();
            LosFormatter formatter = new LosFormatter();

			if (Page.Session[id] == null)
				throw new ArgumentException("session timeout ...");

			string obj = Page.Session[id] as string;
            Pair pair = formatter.Deserialize(obj) as Pair;
            ViewState = pair.First;
            ControlState = pair.Second;
		}
開發者ID:polterguy,項目名稱:magix,代碼行數:13,代碼來源:Magix_PageStatePersister.cs

示例15: LoadPageStateFromPersistenceMedium

		/// <summary>
		/// Loads any saved view-state information to the <see cref="T:System.Web.UI.Page"></see> object.
		/// </summary>
		/// <returns>The saved view state.</returns>
		protected override object LoadPageStateFromPersistenceMedium()
		{
			String viewState =  Request.Params[ViewStateKey];

			if (viewState == null)
			{
				return null;
			}
			else
			{
				LosFormatter formatter = new LosFormatter();
				return formatter.Deserialize(viewState);
			}
		}
開發者ID:nats,項目名稱:castle-1.0.3-mono,代碼行數:18,代碼來源:MasterPageBase.cs


注:本文中的System.Web.UI.LosFormatter類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。