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/DiagramEntityBase.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: 7.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    // ----------------------------------------------------------------------
13    /// <summary>
14    /// Complementary partial class related to (de)serialization.
15    /// </summary>
16    // ----------------------------------------------------------------------
17    [Serializable]
18    public partial class DiagramEntityBase :
19        ISerializable,
20        IXmlSerializable,
21        IDeserializationCallback
22    {
23        #region Deserialization constructor
24
25        // ------------------------------------------------------------------
26        /// <summary>
27        /// Deserialization constructor
28        /// </summary>
29        /// <param name="info">The info.</param>
30        /// <param name="context">The context.</param>
31        // ------------------------------------------------------------------
32        protected DiagramEntityBase(
33            SerializationInfo info,
34            StreamingContext context)
35        {
36            if (Tracing.BinaryDeserializationSwitch.Enabled)
37            {
38                Trace.WriteLine(
39                    "Deserializing the fields of 'DiagramEntityBase'.");
40            }
41            Initialize();
42
43            string version = info.GetString("DiagramEntityBaseVersion");
44            this.mName = info.GetString("Name");
45            this.mSceneIndex = info.GetInt32("SceneIndex");
46            this.mUid = new Guid(info.GetString("Uid"));
47            this.mResizable = info.GetBoolean("Resizable");
48
49            this.mPaintStyle = info.GetValue(
50                "PaintStyle",
51                typeof(IPaintStyle)) as IPaintStyle;
52
53            this.mPenStyle = info.GetValue(
54                "PenStyle",
55                typeof(IPenStyle)) as IPenStyle;
56
57            mAllowDelete = (bool)info.GetValue("AllowDelete", typeof(bool));
58            myMinSize = (Size)info.GetValue("MinSize", typeof(Size));
59            myMaxSize = (Size)info.GetValue("MaxSize", typeof(Size));
60            mVisible = (bool)info.GetValue("Visible", typeof(bool));
61            mEnabled = (bool)info.GetValue("Enabled", typeof(bool));
62        }
63        #endregion
64
65        #region Serialization events
66        /*
67        [OnSerializing]
68        void OnSerializing(StreamingContext context)
69        {
70            Trace.WriteLine("Starting to serializing the 'DiagramEntityBase' class...");
71        }
72        [OnSerialized]
73        void OnSerialized(StreamingContext context)
74        {
75            Trace.WriteLine("...serialization of 'DiagramEntityBase' finished");
76        }
77        */
78        #endregion
79
80        #region Deserialization events
81        /*
82        [OnDeserializing]
83        void OnDeserializing(StreamingContext context)
84        {
85            Trace.Indent();
86            Trace.WriteLine("Starting deserializing the 'DiagramEntityBase' class...");
87        }
88        */
89        [OnDeserialized]
90        void OnDeserialized(StreamingContext context)
91        {
92            if (Tracing.BinaryDeserializationSwitch.Enabled)
93                Trace.WriteLine("...deserialization of 'DiagramEntityBase' finished");
94        }
95
96        #endregion
97
98        #region Serialization
99
100        // ------------------------------------------------------------------
101        /// <summary>
102        /// Populates a <see cref=
103        /// "T:System.Runtime.Serialization.SerializationInfo"></see> with
104        /// the data needed to serialize the target object.
105        /// </summary>
106        /// <param name="info">The
107        /// <see cref="T:System.Runtime.Serialization.SerializationInfo"></see>
108        /// to populate with data.</param>
109        /// <param name="context">The destination (see
110        /// <see cref="T:System.Runtime.Serialization.StreamingContext"></see>)
111        /// for this serialization.</param>
112        /// <exception cref="T:System.Security.SecurityException">The caller
113        /// does not have the required permission. </exception>
114        // ------------------------------------------------------------------
115        public virtual void GetObjectData(
116            SerializationInfo info,
117            StreamingContext context)
118        {
119            if (Tracing.BinarySerializationSwitch.Enabled)
120            {
121                Trace.WriteLine("Serializing the fields of " +
122                    "'DiagramEntityBase'.");
123            }
124
125            info.AddValue("DiagramEntityBaseVersion", diagramEntityBaseVersion);
126            info.AddValue("Name", this.Name);
127            info.AddValue("SceneIndex", this.SceneIndex);
128            info.AddValue("Uid", this.Uid.ToString());
129            info.AddValue("Resizable", this.mResizable);
130            info.AddValue("PaintStyle", this.mPaintStyle, typeof(IPaintStyle));
131            info.AddValue("PenStyle", this.mPenStyle, typeof(IPenStyle));
132            info.AddValue("AllowDelete", mAllowDelete, typeof(bool));
133            info.AddValue("MinSize", myMinSize, typeof(Size));
134            info.AddValue("MaxSize", myMaxSize, typeof(Size));
135            info.AddValue("Visible", mVisible, typeof(bool));
136            info.AddValue("Enabled", mEnabled, typeof(bool));
137        }
138        #endregion
139
140        #region Xml serialization
141        /// <summary>
142        /// This property is reserved, apply the <see cref="T:System.Xml.Serialization.XmlSchemaProviderAttribute"></see> to the class instead.
143        /// </summary>
144        /// <returns>
145        /// 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.
146        /// </returns>
147        public virtual XmlSchema GetSchema()
148        {
149            throw new NotImplementedException("The method or operation is not implemented.");
150        }
151
152        /// <summary>
153        /// Generates an object from its XML representation.
154        /// </summary>
155        /// <param name="reader">The <see cref="T:System.Xml.XmlReader"></see> stream from which the object is deserialized.</param>
156        public virtual void ReadXml(System.Xml.XmlReader reader)
157        {
158            throw new NotImplementedException("The method or operation is not implemented.");
159        }
160
161        /// <summary>
162        /// Converts an object into its XML representation.
163        /// </summary>
164        /// <param name="writer">The <see cref="T:System.Xml.XmlWriter"></see> stream to which the object is serialized.</param>
165        public virtual void WriteXml(System.Xml.XmlWriter writer)
166        {
167            throw new NotImplementedException("The method or operation is not implemented.");
168        }
169        #endregion
170
171        #region IDeserializationCallback Members
172
173        /// <summary>
174        /// Runs when the entire object graph has been deserialized.
175        /// </summary>
176        /// <param name="sender">The object that initiated the callback. The functionality for this parameter is not currently implemented.</param>
177        public virtual void OnDeserialization(object sender)
178        {
179            if (Tracing.BinaryDeserializationSwitch.Enabled)
180                Trace.WriteLine("IDeserializationCallback of 'DiagramEntityBase' called.");
181            UpdatePaintingMaterial();
182        }
183
184        #endregion
185    }
186}
Note: See TracBrowser for help on using the repository browser.