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 IconLabelMaterial : 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 IconLabelMaterial(SerializationInfo info, StreamingContext context)
|
---|
20 | : base(info, context) {
|
---|
21 | if (Tracing.BinaryDeserializationSwitch.Enabled)
|
---|
22 | Trace.WriteLine("Deserializing the fields of 'IconLabelMaterial'.");
|
---|
23 |
|
---|
24 | double version = info.GetDouble("IconLabelMaterialVersion");
|
---|
25 |
|
---|
26 | mText = info.GetString("Text");
|
---|
27 | try {
|
---|
28 | mIcon = info.GetValue("Icon", typeof(Bitmap)) as Bitmap;
|
---|
29 | }
|
---|
30 | catch {
|
---|
31 | }
|
---|
32 | }
|
---|
33 | #endregion
|
---|
34 |
|
---|
35 | #region Serialization events
|
---|
36 | /*
|
---|
37 | [OnSerializing]
|
---|
38 | void OnSerializing(StreamingContext context)
|
---|
39 | {
|
---|
40 | Trace.Indent();
|
---|
41 | Trace.WriteLine("Starting to serializing the 'IconLabelMaterial' class...");
|
---|
42 | }
|
---|
43 | [OnSerialized]
|
---|
44 | void OnSerialized(StreamingContext context)
|
---|
45 | {
|
---|
46 | Trace.WriteLine("...serialization of 'IconLabelMaterial' finished");
|
---|
47 | Trace.Unindent();
|
---|
48 | }
|
---|
49 | */
|
---|
50 | #endregion
|
---|
51 |
|
---|
52 | #region Deserialization events
|
---|
53 | /*
|
---|
54 | [OnDeserializing]
|
---|
55 | void OnDeserializing(StreamingContext context)
|
---|
56 | {
|
---|
57 | Trace.Indent();
|
---|
58 | Trace.WriteLine("IDeserializationCallback of 'IconLabelMaterial' called.");
|
---|
59 | }
|
---|
60 | [OnDeserialized]
|
---|
61 | void OnDeserialized(StreamingContext context)
|
---|
62 | {
|
---|
63 | Trace.WriteLine("...deserialization of 'IconLabelMaterial' finished");
|
---|
64 | Trace.Unindent();
|
---|
65 | }
|
---|
66 | */
|
---|
67 | #endregion
|
---|
68 |
|
---|
69 | #region Serialization
|
---|
70 | /// <summary>
|
---|
71 | /// Populates a <see cref="T:System.Runtime.Serialization.SerializationInfo"></see> with the data needed to serialize the target object.
|
---|
72 | /// </summary>
|
---|
73 | /// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo"></see> to populate with data.</param>
|
---|
74 | /// <param name="context">The destination (see <see cref="T:System.Runtime.Serialization.StreamingContext"></see>) for this serialization.</param>
|
---|
75 | /// <exception cref="T:System.Security.SecurityException">The caller does not have the required permission. </exception>
|
---|
76 | public override void GetObjectData(SerializationInfo info, StreamingContext context) {
|
---|
77 | if (Tracing.BinarySerializationSwitch.Enabled)
|
---|
78 | Trace.WriteLine("Serializing the fields of 'IconLabelMaterial'.");
|
---|
79 | base.GetObjectData(info, context);
|
---|
80 |
|
---|
81 | info.AddValue(
|
---|
82 | "IconLabelMaterialVersion",
|
---|
83 | iconLabelMaterialVersion);
|
---|
84 |
|
---|
85 | if (mIcon != null)
|
---|
86 | info.AddValue("Icon", mIcon, typeof(Bitmap));
|
---|
87 | info.AddValue("Text", this.mText);
|
---|
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 |
|
---|
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 | if (Tracing.BinaryDeserializationSwitch.Enabled)
|
---|
128 | Trace.WriteLine("IDeserializationCallback of 'IconLabelMaterial' called.");
|
---|
129 |
|
---|
130 |
|
---|
131 | }
|
---|
132 | }
|
---|
133 | }
|
---|