- pegasus_library_2_1_20_source.zip
- Pegasus.Library
- Articles
- Pegasus Library - Service Executable.docx
- localtestrun.testrunconfig
- Pegasus.Library.Docs.shfb
- Pegasus.Library.HtmlEditor
- Pegasus.Library.sln
- Pegasus.Library.UnitTests
- Pegasus.Library.vsmdi
- Pegasus.Library.vssscc
- Pegasus.Library
- Pegasus.Library30
- Pegasus.Sample.ExplorerView
- Pegasus.Sample.PeerToPeerChat
- Pegasus.Sample.ServiceDebugging
- pegasus_library_2_1_20_binary.zip
- Pegasus.Library.dll
- Pegasus.Library.HtmlEditor.dll
- Pegasus.Library30.dll
|
using System;
using System.Runtime.Serialization;
namespace Pegasus.UnitTests.Runtime.Serialization.Formatters.Xml.XmlFormatter2Tests
{
/// <summary>
/// This object knows how to serialize/deserialize the NonserializationChild class.
/// </summary>
public class NonChildSerializationSurrogate : ISerializationSurrogate
{
/// <summary>
/// Initializes a new instance of the <see cref="T:NonChildSerializationSurrogate"/> class.
/// </summary>
public NonChildSerializationSurrogate()
{
}
/// <summary>
/// Populates the provided <see cref="T:System.Runtime.Serialization.SerializationInfo"></see> with the data needed to serialize the object.
/// </summary>
/// <param name="obj">The object to serialize.</param>
/// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo"></see> to populate with data.</param>
/// <param name="context">The destination (see <see cref="T:System.Runtime.Serialization.StreamingContext"></see>) for this serialization.</param>
/// <exception cref="T:System.Security.SecurityException">The caller does not have the required permission. </exception>
public void GetObjectData( object obj, SerializationInfo info, StreamingContext context )
{
NonserializationChild child = (NonserializationChild) obj;
info.AddValue( "Name", child.Name );
info.AddValue( "Description", child.Description );
info.AddValue( "Count", child.Count );
}
/// <summary>
/// Populates the object using the information in the <see cref="T:System.Runtime.Serialization.SerializationInfo"></see>.
/// </summary>
/// <param name="obj">The object to populate.</param>
/// <param name="info">The information to populate the object.</param>
/// <param name="context">The source from which the object is deserialized.</param>
/// <param name="selector">The surrogate selector where the search for a compatible surrogate begins.</param>
/// <returns>The populated deserialized object.</returns>
/// <exception cref="T:System.Security.SecurityException">The caller does not have the required permission. </exception>
public object SetObjectData( object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector )
{
NonserializationChild child = (NonserializationChild) obj;
child.Name = info.GetString( "Name" );
child.Description = info.GetString( "Description" );
child.Count = info.GetInt32( "Count" );
return child;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.