Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2901_StaticSelectionMethods/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/Serialization/ShapeBase.Serialization.cs

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

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

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