本文整理汇总了C#中System.Web.UI.LosFormatter.Serialize方法的典型用法代码示例。如果您正苦于以下问题:C# LosFormatter.Serialize方法的具体用法?C# LosFormatter.Serialize怎么用?C# LosFormatter.Serialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.LosFormatter
的用法示例。
在下文中一共展示了LosFormatter.Serialize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Ctor0_Deny_Unrestricted
public void Ctor0_Deny_Unrestricted ()
{
LosFormatter lf = new LosFormatter ();
MemoryStream ms = new MemoryStream ();
lf.Serialize (ms, "mono");
ms.Position = 0;
Assert.IsNotNull (lf.Deserialize (ms), "Deserialize(Stream)");
StringWriter sw = new StringWriter ();
lf.Serialize (sw, "mono");
string s = sw.ToString ();
StringReader sr = new StringReader (s);
Assert.IsNotNull (lf.Deserialize (sr), "Deserialize(TextReader)");
Assert.IsNotNull (lf.Deserialize (s), "Deserialize(string)");
}
示例2: 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();
}
示例3: 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));
}
示例4: 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);
}
示例5: 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);
}
示例6: 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());
}
示例7: 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");
}
示例8: Save
public override void Save()
{
LosFormatter formatter = new LosFormatter();
StringBuilder builder = new StringBuilder();
using (StringWriter writer = new StringWriter(builder))
{
formatter.Serialize(writer, new Pair(ViewState, ControlState));
}
string id = _session.ToString() + "|" + Page.Request.Url.ToString().Replace(" ", "+");
Page.Session[id] = builder.ToString();
}
示例9: SavePageStateToPersistenceMedium
protected override void SavePageStateToPersistenceMedium(object pageViewState)
{
MemoryStream ms = new MemoryStream();
LosFormatter m_formatter = new LosFormatter();
m_formatter.Serialize(ms, pageViewState);
ms.Position = 0;
StreamReader sr = new StreamReader(ms);
string viewStateString = sr.ReadToEnd();
byte[] ViewStateBytes = Convert.FromBase64String(viewStateString);
ViewStateBytes = ViewStateCompression.Compress(ViewStateBytes);
Session["ViewState"] = Convert.ToBase64String(ViewStateBytes);
ms.Close();
return;
}
示例10: SavePageStateToPersistenceMedium
protected override void SavePageStateToPersistenceMedium( object viewState )
{
LosFormatter format = new LosFormatter();
StringWriter writer = new StringWriter();
format.Serialize( writer, viewState );
string viewStateStr = writer.ToString();
byte[] bytes = System.Convert.FromBase64String( viewStateStr );
bytes = this.Compress( bytes );
string vStateStr = System.Convert.ToBase64String( bytes );
ClientScript.RegisterHiddenField( "__VSTATE", vStateStr );
}
示例11: Save
public override void Save()
{
Pair pair = new Pair();
if (base.ViewState != null)
pair.First = base.ViewState;
if (base.ControlState != null)
pair.Second = base.ControlState;
//
LosFormatter los = new LosFormatter();
StringWriter writer = new StringWriter();
los.Serialize(writer, pair);
StreamWriter sw = File.CreateText(ViewStateFilePath);
sw.Write(writer.ToString());
sw.Close();
}
示例12: SavePageStateToPersistenceMedium
protected override void SavePageStateToPersistenceMedium(object state)
{
string file = GenerateFileName(true);
FileStream filestream = new FileStream(file, FileMode.Create);
LosFormatter formator = new LosFormatter();
formator.Serialize(filestream, state);
filestream.Flush();
filestream.Close();
filestream = null;
}
示例13: SavePageStateToPersistenceMedium
protected override void SavePageStateToPersistenceMedium(object viewState)
{
this._viewstateStorage = ViewstateStorageFactory.GetStorageMedium();
_config = (ViewStateConfiguration) ConfigurationManager.GetSection("ViewStateConfiguration");
LosFormatter formatter = new LosFormatter();
StringWriter writer = new StringWriter();
formatter.Serialize(writer, viewState);
string viewStateString = writer.ToString();
byte[] bytes = Convert.FromBase64String(viewStateString);
if (_config.Compression)
bytes = bytes.Compress();
string viewstateBase64 = Convert.ToBase64String(bytes);
string id = ViewstateStorageFactory.GetUserUniqueID().GetUniqueID();
this._viewstateStorage.Add(new KeyValuePair<object, string>(id, viewstateBase64));
ScriptManager.RegisterHiddenField(this, "__VIEWSTATE_UniqueID", id);
}
示例14: Serialize_Output
public void Serialize_Output ()
{
string s = "Hello world";
LosFormatter lf = new LosFormatter ();
StringWriter sw = new StringWriter ();
lf.Serialize (sw, s);
string s1 = sw.ToString ();
#if NET_2_0
Assert.AreEqual ("/wEFC0hlbGxvIHdvcmxk", s1, "#1");
#else
Assert.AreEqual ("SGVsbG8gd29ybGQ=", s1, "#1");
#endif
string s2 = lf.Deserialize (s1) as string;
Assert.IsNotNull (s2, "#2");
Assert.AreEqual (s, s2, "#3");
}
示例15: SavePageStateToPersistenceMedium
protected override void SavePageStateToPersistenceMedium(object state)
{
LosFormatter formatter = new LosFormatter();
StringWriter writer = new StringWriter();
formatter.Serialize(writer, state);
string viewStateString = writer.ToString();
byte[] bytes = Convert.FromBase64String(viewStateString);
this.normalViewState.Text = viewStateString;
bytes = bytes.Compress();
this.encryptedViewState.Text = Convert.ToBase64String(bytes);
ClientScript.RegisterHiddenField("__VSTATE", Convert.ToBase64String(bytes));
}