Free cookie consent management tool by TermsFeed Policy Generator

source: stable/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/Serialization/GroupShape.Serialization.cs @ 15973

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

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

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