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 @ 2768

Last change on this file since 2768 was 2768, checked in by mkommend, 14 years ago

added solution folders and sources for the netron library (ticket #867)

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