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