using System;
using System.Diagnostics;
using System.Drawing;
using System.Runtime.Serialization;
using System.Xml.Schema;
using System.Xml.Serialization;
namespace Netron.Diagramming.Core {
// ----------------------------------------------------------------------
///
/// Complementary partial class related to (de)serialization.
///
// ----------------------------------------------------------------------
[Serializable]
public partial class DiagramEntityBase :
ISerializable,
IXmlSerializable,
IDeserializationCallback {
#region Deserialization constructor
// ------------------------------------------------------------------
///
/// Deserialization constructor
///
/// The info.
/// The context.
// ------------------------------------------------------------------
protected DiagramEntityBase(
SerializationInfo info,
StreamingContext context) {
if (Tracing.BinaryDeserializationSwitch.Enabled) {
Trace.WriteLine(
"Deserializing the fields of 'DiagramEntityBase'.");
}
Initialize();
string version = info.GetString("DiagramEntityBaseVersion");
this.mName = info.GetString("Name");
this.mSceneIndex = info.GetInt32("SceneIndex");
this.mUid = new Guid(info.GetString("Uid"));
this.mResizable = info.GetBoolean("Resizable");
this.mPaintStyle = info.GetValue(
"PaintStyle",
typeof(IPaintStyle)) as IPaintStyle;
this.mPenStyle = info.GetValue(
"PenStyle",
typeof(IPenStyle)) as IPenStyle;
mAllowDelete = (bool)info.GetValue("AllowDelete", typeof(bool));
myMinSize = (Size)info.GetValue("MinSize", typeof(Size));
myMaxSize = (Size)info.GetValue("MaxSize", typeof(Size));
mVisible = (bool)info.GetValue("Visible", typeof(bool));
mEnabled = (bool)info.GetValue("Enabled", typeof(bool));
}
#endregion
#region Serialization events
/*
[OnSerializing]
void OnSerializing(StreamingContext context)
{
Trace.WriteLine("Starting to serializing the 'DiagramEntityBase' class...");
}
[OnSerialized]
void OnSerialized(StreamingContext context)
{
Trace.WriteLine("...serialization of 'DiagramEntityBase' finished");
}
*/
#endregion
#region Deserialization events
/*
[OnDeserializing]
void OnDeserializing(StreamingContext context)
{
Trace.Indent();
Trace.WriteLine("Starting deserializing the 'DiagramEntityBase' class...");
}
*/
[OnDeserialized]
void OnDeserialized(StreamingContext context) {
if (Tracing.BinaryDeserializationSwitch.Enabled)
Trace.WriteLine("...deserialization of 'DiagramEntityBase' finished");
}
#endregion
#region Serialization
// ------------------------------------------------------------------
///
/// Populates a with
/// the data needed to serialize the target object.
///
/// The
///
/// to populate with data.
/// The destination (see
/// )
/// for this serialization.
/// The caller
/// does not have the required permission.
// ------------------------------------------------------------------
public virtual void GetObjectData(
SerializationInfo info,
StreamingContext context) {
if (Tracing.BinarySerializationSwitch.Enabled) {
Trace.WriteLine("Serializing the fields of " +
"'DiagramEntityBase'.");
}
info.AddValue("DiagramEntityBaseVersion", diagramEntityBaseVersion);
info.AddValue("Name", this.Name);
info.AddValue("SceneIndex", this.SceneIndex);
info.AddValue("Uid", this.Uid.ToString());
info.AddValue("Resizable", this.mResizable);
info.AddValue("PaintStyle", this.mPaintStyle, typeof(IPaintStyle));
info.AddValue("PenStyle", this.mPenStyle, typeof(IPenStyle));
info.AddValue("AllowDelete", mAllowDelete, typeof(bool));
info.AddValue("MinSize", myMinSize, typeof(Size));
info.AddValue("MaxSize", myMaxSize, typeof(Size));
info.AddValue("Visible", mVisible, typeof(bool));
info.AddValue("Enabled", mEnabled, typeof(bool));
}
#endregion
#region Xml serialization
///
/// This property is reserved, apply the to the class instead.
///
///
/// An that describes the XML representation of the object that is produced by the method and consumed by the method.
///
public virtual XmlSchema GetSchema() {
throw new NotImplementedException("The method or operation is not implemented.");
}
///
/// Generates an object from its XML representation.
///
/// The stream from which the object is deserialized.
public virtual void ReadXml(System.Xml.XmlReader reader) {
throw new NotImplementedException("The method or operation is not implemented.");
}
///
/// Converts an object into its XML representation.
///
/// The stream to which the object is serialized.
public virtual void WriteXml(System.Xml.XmlWriter writer) {
throw new NotImplementedException("The method or operation is not implemented.");
}
#endregion
#region IDeserializationCallback Members
///
/// Runs when the entire object graph has been deserialized.
///
/// The object that initiated the callback. The functionality for this parameter is not currently implemented.
public virtual void OnDeserialization(object sender) {
if (Tracing.BinaryDeserializationSwitch.Enabled)
Trace.WriteLine("IDeserializationCallback of 'DiagramEntityBase' called.");
UpdatePaintingMaterial();
}
#endregion
}
}