本文整理汇总了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
}
示例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));
}
示例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;
}
示例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;
}
示例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));
}
示例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));
}
示例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();
}
示例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);
}
示例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 ) );
}
示例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);
}
示例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;
}
示例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());
}
示例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");
}
示例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;
}
示例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);
}
}