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/GroupShape.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.2 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 GroupShape : 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 GroupShape(SerializationInfo info, StreamingContext context) : base(info, context)
25        {
26            if(Tracing.BinaryDeserializationSwitch.Enabled)
27                Trace.WriteLine("Deserializing the fields of 'GroupShape'.");
28
29            double version = info.GetDouble("GroupShapeVersion");
30            mAllowUnGroup = info.GetBoolean("CanUngroup");
31            mEntities = info.GetValue("Entities",
32                typeof(CollectionBase<IDiagramEntity>)) as
33                CollectionBase<IDiagramEntity>;
34        }
35        #endregion
36
37        #region Serialization events
38       /*
39        [OnSerializing]
40        void OnSerializing(StreamingContext context)
41        {
42            Trace.WriteLine("Starting to serializing the 'GroupShape' class...");
43        }
44        [OnSerialized]
45        void OnSerialized(StreamingContext context)
46        {
47            Trace.WriteLine("...serialization of 'GroupShape' finished");
48        }
49        */
50        #endregion
51
52        #region Deserialization events
53       /*
54        [OnDeserializing]
55        void OnDeserializing(StreamingContext context)
56        {
57            Trace.Indent();
58            Trace.WriteLine("Starting deserializing the 'GroupShape' class...");
59        }
60        */
61        [OnDeserialized]
62        void OnDeserialized(StreamingContext context)
63         {
64             if (Tracing.BinaryDeserializationSwitch.Enabled)
65                Trace.WriteLine("...deserialization of 'GroupShape' finished");
66
67            foreach (IDiagramEntity entity in mEntities)
68                entity.Group = this;
69
70             //this.mEntities.OnItemAdded += new EventHandler<CollectionEventArgs<IDiagramEntity>>(mEntities_OnItemAdded);
71             //this.mEntities.OnClear += new EventHandler(mEntities_OnClear);
72             //this.mEntities.OnItemRemoved += new EventHandler<CollectionEventArgs<IDiagramEntity>>(mEntities_OnItemRemoved);
73            AttachEventsToEnityCollection(mEntities);
74            CalculateRectangle();
75         }
76       
77        #endregion
78
79        #region Serialization
80         /// <summary>
81         /// Populates a <see cref="T:System.Runtime.Serialization.SerializationInfo"></see> with the data needed to serialize the target object.
82         /// </summary>
83         /// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo"></see> to populate with data.</param>
84         /// <param name="context">The destination (see <see cref="T:System.Runtime.Serialization.StreamingContext"></see>) for this serialization.</param>
85         /// <exception cref="T:System.Security.SecurityException">The caller does not have the required permission. </exception>
86        public override void GetObjectData(SerializationInfo info, StreamingContext context)
87        {
88            if(Tracing.BinarySerializationSwitch.Enabled)
89                Trace.WriteLine("Serializing the fields of 'GroupShape'.");
90            base.GetObjectData(info, context);
91
92            info.AddValue("GroupShapeVersion", groupShapeVersion);
93            info.AddValue("CanUngroup", mAllowUnGroup);
94            info.AddValue("Entities", this.mEntities, typeof(CollectionBase<IShapeMaterial>));
95           
96        }
97        #endregion
98
99        #region Xml serialization
100        /// <summary>
101        /// This property is reserved, apply the <see cref="T:System.Xml.Serialization.XmlSchemaProviderAttribute"></see> to the class instead.
102        /// </summary>
103        /// <returns>
104        /// 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.
105        /// </returns>
106        public override XmlSchema GetSchema()
107        {
108            throw new NotImplementedException("The method or operation is not implemented.");
109        }
110
111        /// <summary>
112        /// Generates an object from its XML representation.
113        /// </summary>
114        /// <param name="reader">The <see cref="T:System.Xml.XmlReader"></see> stream from which the object is deserialized.</param>
115        public override void ReadXml(System.Xml.XmlReader reader)
116        {
117            throw new NotImplementedException("The method or operation is not implemented.");
118        }
119
120        /// <summary>
121        /// Converts an object into its XML representation.
122        /// </summary>
123        /// <param name="writer">The <see cref="T:System.Xml.XmlWriter"></see> stream to which the object is serialized.</param>
124        public override void WriteXml(System.Xml.XmlWriter writer)
125        {
126            throw new NotImplementedException("The method or operation is not implemented.");
127        }
128        #endregion
129
130        #region IDeserializationCallback Members
131
132        /// <summary>
133        /// Runs when the entire object graph has been deserialized.
134        /// </summary>
135        /// <param name="sender">The object that initiated the callback. The functionality for this parameter is not currently implemented.</param>
136        public override void OnDeserialization(object sender)
137        {
138            base.OnDeserialization(sender);
139     
140
141            if(Tracing.BinaryDeserializationSwitch.Enabled)
142                Trace.WriteLine("IDeserializationCallback of 'GroupShape' called.");
143        }
144
145        #endregion
146    }
147}
Note: See TracBrowser for help on using the repository browser.