1 | using System;
|
---|
2 | using System.Diagnostics;
|
---|
3 | using System.Drawing;
|
---|
4 | using System.Runtime.Serialization;
|
---|
5 | using System.Xml.Schema;
|
---|
6 | using System.Xml.Serialization;
|
---|
7 | namespace Netron.Diagramming.Core {
|
---|
8 | /// <summary>
|
---|
9 | /// Complementary partial class related to (de)serialization.
|
---|
10 | /// </summary>
|
---|
11 | [Serializable]
|
---|
12 | public partial class IconMaterial : 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 IconMaterial(SerializationInfo info, StreamingContext context)
|
---|
20 | : base(info, context) {
|
---|
21 | if (Tracing.BinaryDeserializationSwitch.Enabled)
|
---|
22 | Trace.WriteLine("Deserializing the fields of 'IconMaterial'.");
|
---|
23 |
|
---|
24 | double version = info.GetDouble("IconMaterialVersion");
|
---|
25 |
|
---|
26 | try {
|
---|
27 | mIcon = info.GetValue("Icon", typeof(Bitmap)) as Bitmap;
|
---|
28 | }
|
---|
29 | catch {
|
---|
30 | //never mind, there was no icon originally in the material
|
---|
31 | }
|
---|
32 |
|
---|
33 | }
|
---|
34 | #endregion
|
---|
35 |
|
---|
36 | #region Serialization events
|
---|
37 | /*
|
---|
38 | [OnSerializing]
|
---|
39 | void OnSerializing(StreamingContext context)
|
---|
40 | {
|
---|
41 | Trace.Indent();
|
---|
42 | Trace.WriteLine("Starting to serializing the 'IconMaterial' class...");
|
---|
43 | }
|
---|
44 | [OnSerialized]
|
---|
45 | void OnSerialized(StreamingContext context)
|
---|
46 | {
|
---|
47 | Trace.WriteLine("...serialization of 'IconMaterial' finished");
|
---|
48 | Trace.Unindent();
|
---|
49 | }
|
---|
50 | */
|
---|
51 | #endregion
|
---|
52 |
|
---|
53 | #region Deserialization events
|
---|
54 | /*
|
---|
55 | [OnDeserializing]
|
---|
56 | void OnDeserializing(StreamingContext context)
|
---|
57 | {
|
---|
58 | Trace.Indent();
|
---|
59 | Trace.WriteLine("IDeserializationCallback of 'IconMaterial' called.");
|
---|
60 | }
|
---|
61 | [OnDeserialized]
|
---|
62 | void OnDeserialized(StreamingContext context)
|
---|
63 | {
|
---|
64 | Trace.WriteLine("...deserialization of 'IconMaterial' finished");
|
---|
65 | Trace.Unindent();
|
---|
66 | }
|
---|
67 | */
|
---|
68 | #endregion
|
---|
69 |
|
---|
70 | #region Serialization
|
---|
71 | public override void GetObjectData(SerializationInfo info, StreamingContext context) {
|
---|
72 | if (Tracing.BinarySerializationSwitch.Enabled)
|
---|
73 | Trace.WriteLine("Serializing the fields of 'IconMaterial'.");
|
---|
74 | base.GetObjectData(info, context);
|
---|
75 |
|
---|
76 | info.AddValue("IconMaterialVersion", iconMaterialVersion);
|
---|
77 | if (mIcon != null)
|
---|
78 | info.AddValue("Icon", mIcon, typeof(Bitmap));
|
---|
79 | }
|
---|
80 | #endregion
|
---|
81 |
|
---|
82 | #region Xml serialization
|
---|
83 | /// <summary>
|
---|
84 | /// This property is reserved, apply the <see cref="T:System.Xml.Serialization.XmlSchemaProviderAttribute"></see> to the class instead.
|
---|
85 | /// </summary>
|
---|
86 | /// <returns>
|
---|
87 | /// 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.
|
---|
88 | /// </returns>
|
---|
89 | public override XmlSchema GetSchema() {
|
---|
90 | throw new NotImplementedException("The method or operation is not implemented.");
|
---|
91 | }
|
---|
92 |
|
---|
93 | /// <summary>
|
---|
94 | /// Generates an object from its XML representation.
|
---|
95 | /// </summary>
|
---|
96 | /// <param name="reader">The <see cref="T:System.Xml.XmlReader"></see> stream from which the object is deserialized.</param>
|
---|
97 | public override void ReadXml(System.Xml.XmlReader reader) {
|
---|
98 | throw new NotImplementedException("The method or operation is not implemented.");
|
---|
99 | }
|
---|
100 |
|
---|
101 | /// <summary>
|
---|
102 | /// Converts an object into its XML representation.
|
---|
103 | /// </summary>
|
---|
104 | /// <param name="writer">The <see cref="T:System.Xml.XmlWriter"></see> stream to which the object is serialized.</param>
|
---|
105 | public override void WriteXml(System.Xml.XmlWriter writer) {
|
---|
106 | throw new NotImplementedException("The method or operation is not implemented.");
|
---|
107 | }
|
---|
108 | #endregion
|
---|
109 |
|
---|
110 |
|
---|
111 |
|
---|
112 | /// <summary>
|
---|
113 | /// Runs when the entire object graph has been deserialized.
|
---|
114 | /// </summary>
|
---|
115 | /// <param name="sender">The object that initiated the callback. The functionality for this parameter is not currently implemented.</param>
|
---|
116 | public override void OnDeserialization(object sender) {
|
---|
117 | base.OnDeserialization(sender);
|
---|
118 | if (Tracing.BinaryDeserializationSwitch.Enabled)
|
---|
119 | Trace.WriteLine("IDeserializationCallback of 'IconMaterial' called.");
|
---|
120 |
|
---|
121 |
|
---|
122 | }
|
---|
123 | }
|
---|
124 | }
|
---|