using System; using System.Runtime.Serialization; namespace Pegasus.UnitTests.Runtime.Serialization.Formatters.Xml.XmlFormatter2Tests { /// <summary> /// This class is used to test the OnSerializedAttribute and OnSerializingAttribute /// /// </summary> [Serializable] public class OnSerializationEventsObject : IDeserializationCallback { // Local Intance Values private string m_name; [NonSerialized] private bool m_serializing = false; [NonSerialized] private bool m_serialized = false; [NonSerialized] private bool m_deserializing = false; [NonSerialized] private bool m_deserialized = false; [NonSerialized] private bool m_deserializeProcessComplete = false; /// <summary> /// Initializes a new instance of the <see cref="T:OnSerializationEventsObject"/> class. /// </summary> public OnSerializationEventsObject() { } /// <summary> /// Gets or sets the name. /// </summary> /// <value>The name.</value> public string Name { get { return m_name; } set { m_name = value; } } /// <summary> /// Gets a value indicating whether this <see cref="T:OnSerializationEventsObject"/> is serializing. /// </summary> /// <value><c>true</c> if serializing; otherwise, <c>false</c>.</value> public bool Serializing { get { return m_serializing; } } /// <summary> /// Gets a value indicating whether this <see cref="T:OnSerializationEventsObject"/> is serialized. /// </summary> /// <value><c>true</c> if serialized; otherwise, <c>false</c>.</value> public bool Serialized { get { return m_serialized; } } /// <summary> /// Gets a value indicating whether this <see cref="T:OnSerializationEventsObject"/> is deserializing. /// </summary> /// <value><c>true</c> if deserializing; otherwise, <c>false</c>.</value> public bool Deserializing { get { return m_deserializing; } } /// <summary> /// Gets a value indicating whether this <see cref="T:OnSerializationEventsObject"/> is deserialized. /// </summary> /// <value><c>true</c> if deserialized; otherwise, <c>false</c>.</value> public bool Deserialized { get { return m_deserialized; } } /// <summary> /// Gets a value indicating whether [deserialize process complete]. /// </summary> /// <value> /// <c>true</c> if [deserialize process complete]; otherwise, <c>false</c>. /// </value> public bool DeserializeProcessComplete { get { return m_deserializeProcessComplete; } } /// <summary> /// Called when [serializing method]. /// </summary> /// <param name="context">The context.</param> [OnSerializing] internal void OnSerializingMethod( StreamingContext context ) { m_serializing = true; } /// <summary> /// Called when [serialized method]. /// </summary> /// <param name="context">The context.</param> [OnSerialized] internal void OnSerializedMethod( StreamingContext context ) { m_serialized = true; } /// <summary> /// Called when [deserializing method]. /// </summary> /// <param name="context">The context.</param> [OnDeserializing] internal void OnDeserializingMethod( StreamingContext context ) { m_deserializing = true; } /// <summary> /// Called when [deserialized method]. /// </summary> /// <param name="context">The context.</param> [OnDeserialized] internal void OnDeserializedMethod( StreamingContext context ) { m_deserialized = true; } /// <summary> /// Runs when the entire object graph has been deserialized. /// </summary> /// <param name="sender">The object that initiated the callback. The functionality for this parameter is not currently implemented.</param> public void OnDeserialization( object sender ) { m_deserializeProcessComplete = true; } } }
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 article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)