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/FolderMaterial.Serialization.cs @ 13400

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

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

File size: 6.2 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 FolderMaterial : 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 FolderMaterial(SerializationInfo info, StreamingContext context) {
20      if (Tracing.BinaryDeserializationSwitch.Enabled)
21        Trace.WriteLine("Deserializing the fields of 'FolderMaterial'.");
22
23      double version = info.GetDouble("FolderMaterialVersion");
24
25      this.Gliding = info.GetBoolean("Gliding");
26      this.Resizable = info.GetBoolean("Resizable");
27      this.Visible = info.GetBoolean("Visible");
28      header = info.GetValue("Header", typeof(ClickableLabelMaterial)) as ClickableLabelMaterial;
29      plusminus = info.GetValue("PlusMinus", typeof(SwitchIconMaterial)) as SwitchIconMaterial;
30      mEntries = info.GetValue("Entries", typeof(CollectionBase<IShapeMaterial>)) as CollectionBase<IShapeMaterial>;
31      mEntries.OnItemAdded += new EventHandler<CollectionEventArgs<IShapeMaterial>>(mEntries_OnItemAdded);
32      Rectangle = (Rectangle)info.GetValue("Rectangle", typeof(Rectangle));
33
34      mCollapsed = info.GetBoolean("Collapsed");
35    }
36    #endregion
37
38    #region Serialization events
39    /*
40        [OnSerializing]
41        void OnSerializing(StreamingContext context)
42        {
43            Trace.Indent();
44            Trace.WriteLine("Starting to serializing the 'FolderMaterial' class...");
45        }
46        [OnSerialized]
47        void OnSerialized(StreamingContext context)
48        {
49            Trace.WriteLine("...serialization of 'FolderMaterial' finished");
50            Trace.Unindent();
51        }
52        */
53    #endregion
54
55    #region Deserialization events
56    /*
57        [OnDeserializing]     
58        void OnDeserializing(StreamingContext context)
59        {
60            Trace.Indent();
61            Trace.WriteLine("IDeserializationCallback of 'FolderMaterial' called.");
62        }
63        * */
64    [OnDeserialized]
65    void OnDeserialized(StreamingContext context) {
66      if (Tracing.BinaryDeserializationSwitch.Enabled)
67        Trace.WriteLine("...deserialization of 'FolderMaterial' finished");
68      foreach (IShapeMaterial material in mEntries) {
69        material.Shape = this.Shape;
70      }
71      plusminus.OnExpand += new EventHandler(plusminus_OnExpand);
72      plusminus.OnCollapse += new EventHandler(plusminus_OnCollapse);
73      plusminus.Collapsed = mCollapsed;//this will call the Expand/Collapse of the folder via the event in the lines above           
74
75      Transform(Rectangle);
76
77    }
78
79    #endregion
80
81    #region Serialization
82    /// <summary>
83    /// Populates a <see cref="T:System.Runtime.Serialization.SerializationInfo"></see> with the data needed to serialize the target object.
84    /// </summary>
85    /// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo"></see> to populate with data.</param>
86    /// <param name="context">The destination (see <see cref="T:System.Runtime.Serialization.StreamingContext"></see>) for this serialization.</param>
87    /// <exception cref="T:System.Security.SecurityException">The caller does not have the required permission. </exception>
88    public override void GetObjectData(SerializationInfo info, StreamingContext context) {
89      if (Tracing.BinarySerializationSwitch.Enabled)
90        Trace.WriteLine("Serializing the fields of 'FolderMaterial'.");
91      base.GetObjectData(info, context);
92
93      info.AddValue("FolderMaterialVersion", folderMaterialVersion);
94      info.AddValue("Header", this.header, typeof(ClickableLabelMaterial));
95      info.AddValue("PlusMinus", this.plusminus, typeof(SwitchIconMaterial));
96      info.AddValue("Entries", this.mEntries, typeof(CollectionBase<IShapeMaterial>));
97      info.AddValue("Collapsed", mCollapsed);
98    }
99    #endregion
100
101    #region Xml serialization
102    /// <summary>
103    /// This property is reserved, apply the <see cref="T:System.Xml.Serialization.XmlSchemaProviderAttribute"></see> to the class instead.
104    /// </summary>
105    /// <returns>
106    /// 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.
107    /// </returns>
108    public override XmlSchema GetSchema() {
109      throw new NotImplementedException("The method or operation is not implemented.");
110    }
111
112    /// <summary>
113    /// Generates an object from its XML representation.
114    /// </summary>
115    /// <param name="reader">The <see cref="T:System.Xml.XmlReader"></see> stream from which the object is deserialized.</param>
116    public override void ReadXml(System.Xml.XmlReader reader) {
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      throw new NotImplementedException("The method or operation is not implemented.");
126    }
127    #endregion
128
129
130
131    /// <summary>
132    /// Runs when the entire object graph has been deserialized.
133    /// </summary>
134    /// <param name="sender">The object that initiated the callback. The functionality for this parameter is not currently implemented.</param>
135    public override void OnDeserialization(object sender) {
136      base.OnDeserialization(sender);
137      if (Tracing.BinaryDeserializationSwitch.Enabled)
138        Trace.WriteLine("IDeserializationCallback of 'FolderMaterial' called.");
139
140
141    }
142  }
143}
Note: See TracBrowser for help on using the repository browser.