Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/Serialization/Page.Serialization.cs @ 4068

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

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

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