Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/Serialization/SimpleShapeBase.Serialization.cs @ 18009

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

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

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