Free cookie consent management tool by TermsFeed Policy Generator

source: stable/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/Serialization/ConnectionBase.Serialization.cs @ 15973

Last change on this file since 15973 was 4068, checked in by swagner, 14 years ago

Sorted usings and removed unused usings in entire solution (#1094)

File size: 6.1 KB
Line 
1using System;
2using System.Diagnostics;
3using System.Runtime.Serialization;
4using System.Xml.Schema;
5using System.Xml.Serialization;
6namespace Netron.Diagramming.Core {
7  // ----------------------------------------------------------------------
8  /// <summary>
9  /// Complementary partial class related to (de)serialization.
10  /// </summary>
11  // ----------------------------------------------------------------------
12  [Serializable]
13  public abstract partial class ConnectionBase :
14     ISerializable,
15     IXmlSerializable,
16     IDeserializationCallback {
17    #region Deserialization constructor
18
19    // ------------------------------------------------------------------
20    /// <summary>
21    /// Deserialization constructor
22    /// </summary>
23    /// <param name="info">The info.</param>
24    /// <param name="context">The context.</param>
25    // ------------------------------------------------------------------
26    protected ConnectionBase(
27        SerializationInfo info,
28        StreamingContext context)
29      : base(info, context) {
30      if (Tracing.BinaryDeserializationSwitch.Enabled) {
31        Trace.WriteLine(
32            "Deserializing the fields of 'ConnectionBase'.");
33      }
34
35      double version = info.GetDouble("ConnectionBaseVersion");
36      mTo = info.GetValue("To", typeof(Connector)) as Connector;
37      mFrom = info.GetValue("From", typeof(Connector)) as Connector;
38
39      if (mTo == null) {
40        throw new InconsistencyException(
41            "'To' connector deserialized to 'null'");
42      }
43      if (mFrom == null) {
44        throw new InconsistencyException(
45            "'From' connector deserialized to 'null'");
46      }
47
48      mTo.Parent = this;
49      mFrom.Parent = this;
50
51    }
52
53    #endregion
54
55    #region Serialization events
56    /*
57        [OnSerializing]
58        void OnSerializing(StreamingContext context)
59        {
60            Trace.WriteLine("Starting to serializing the 'ConnectionBase' class...");
61        }
62        [OnSerialized]
63        void OnSerialized(StreamingContext context)
64        {           
65            Trace.WriteLine("...serialization of 'ConnectionBase' finished");
66        }
67        */
68    #endregion
69
70    #region Deserialization events
71    /*
72        [OnDeserializing]
73        void OnDeserializing(StreamingContext context)
74        {
75            Trace.Indent();
76            Trace.WriteLine("Starting deserializing the 'ConnectionBase' class...");
77        }
78        [OnDeserialized]
79        void OnDeserialized(StreamingContext context)
80         {
81             Trace.WriteLine("...deserialization of 'ConnectionBase' finished");
82             Trace.Unindent();
83         }
84       */
85    #endregion
86
87    #region Serialization
88
89    // ------------------------------------------------------------------
90    /// <summary>
91    /// Populates a <see cref=
92    /// "T:System.Runtime.Serialization.SerializationInfo"></see> with
93    /// the data needed to serialize the target object.
94    /// </summary>
95    /// <param name="info">The <see cref=
96    /// "T:System.Runtime.Serialization.SerializationInfo"></see> to
97    /// populate with data.</param>
98    /// <param name="context">The destination (see <see cref=
99    /// "T:System.Runtime.Serialization.StreamingContext"></see>) for
100    /// this serialization.</param>
101    /// <exception cref="T:System.Security.SecurityException">The caller
102    /// does not have the required permission. </exception>
103    // ------------------------------------------------------------------
104    public override void GetObjectData(
105        SerializationInfo info,
106        StreamingContext context) {
107      if (Tracing.BinarySerializationSwitch.Enabled) {
108        Trace.WriteLine(
109            "Serializing the fields of 'ConnectionBase'.");
110      }
111
112      base.GetObjectData(info, context);
113      info.AddValue("From", this.From, typeof(Connector));
114      info.AddValue("To", this.To, typeof(Connector));
115      info.AddValue("ConnectionBaseVersion", connectionBaseVersion);
116    }
117    #endregion
118
119    #region Xml serialization
120    /// <summary>
121    /// This property is reserved, apply the <see cref="T:System.Xml.Serialization.XmlSchemaProviderAttribute"></see> to the class instead.
122    /// </summary>
123    /// <returns>
124    /// An <see cref="T:System.Xml.Schema.XmlSchema"></see> that describes the XML representation of the object that is produced by the <see cref="M:System.Xml.Serialization.IXmlSerializable.WriteXml(System.Xml.XmlWriter)"></see> method and consumed by the <see cref="M:System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader)"></see> method.
125    /// </returns>
126    public override XmlSchema GetSchema() {
127      throw new NotImplementedException("The method or operation is not implemented.");
128    }
129
130    /// <summary>
131    /// Generates an object from its XML representation.
132    /// </summary>
133    /// <param name="reader">The <see cref="T:System.Xml.XmlReader"></see> stream from which the object is deserialized.</param>
134    public override void ReadXml(System.Xml.XmlReader reader) {
135      throw new NotImplementedException("The method or operation is not implemented.");
136    }
137
138    /// <summary>
139    /// Converts an object into its XML representation.
140    /// </summary>
141    /// <param name="writer">The <see cref="T:System.Xml.XmlWriter"></see> stream to which the object is serialized.</param>
142    public override void WriteXml(System.Xml.XmlWriter writer) {
143      throw new NotImplementedException("The method or operation is not implemented.");
144    }
145    #endregion
146
147    #region IDeserializationCallback Members
148
149    /// <summary>
150    /// Runs when the entire object graph has been deserialized.
151    /// </summary>
152    /// <param name="sender">The object that initiated the callback. The functionality for this parameter is not currently implemented.</param>
153    public override void OnDeserialization(object sender) {
154      base.OnDeserialization(sender);
155      if (Tracing.BinaryDeserializationSwitch.Enabled)
156        Trace.WriteLine("IDeserializationCallback of 'ConnectionBase' called.");
157    }
158
159    #endregion
160  }
161}
Note: See TracBrowser for help on using the repository browser.