Changeset 4068 for trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/Serialization/DiagramEntityBase.Serialization.cs
- Timestamp:
- 07/22/10 00:44:01 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/Serialization/DiagramEntityBase.Serialization.cs
r2768 r4068 1 1 using System; 2 using System.Collections.Generic; 3 using System.Text; 2 using System.Diagnostics; 4 3 using System.Drawing; 5 using System.ComponentModel;6 4 using System.Runtime.Serialization; 5 using System.Xml.Schema; 7 6 using System.Xml.Serialization; 8 using System.Diagnostics; 9 using System.Xml.Schema; 10 namespace Netron.Diagramming.Core 11 { 12 // ---------------------------------------------------------------------- 7 namespace Netron.Diagramming.Core { 8 // ---------------------------------------------------------------------- 9 /// <summary> 10 /// Complementary partial class related to (de)serialization. 11 /// </summary> 12 // ---------------------------------------------------------------------- 13 [Serializable] 14 public partial class DiagramEntityBase : 15 ISerializable, 16 IXmlSerializable, 17 IDeserializationCallback { 18 #region Deserialization constructor 19 20 // ------------------------------------------------------------------ 13 21 /// <summary> 14 /// Complementary partial class related to (de)serialization.22 /// Deserialization constructor 15 23 /// </summary> 16 // ---------------------------------------------------------------------- 17 [Serializable] 18 public partial class DiagramEntityBase : 19 ISerializable, 20 IXmlSerializable, 21 IDeserializationCallback 22 { 23 #region Deserialization constructor 24 /// <param name="info">The info.</param> 25 /// <param name="context">The context.</param> 26 // ------------------------------------------------------------------ 27 protected DiagramEntityBase( 28 SerializationInfo info, 29 StreamingContext context) { 30 if (Tracing.BinaryDeserializationSwitch.Enabled) { 31 Trace.WriteLine( 32 "Deserializing the fields of 'DiagramEntityBase'."); 33 } 34 Initialize(); 24 35 25 // ------------------------------------------------------------------ 26 /// <summary> 27 /// Deserialization constructor 28 /// </summary> 29 /// <param name="info">The info.</param> 30 /// <param name="context">The context.</param> 31 // ------------------------------------------------------------------ 32 protected DiagramEntityBase( 33 SerializationInfo info, 34 StreamingContext context) 35 { 36 if (Tracing.BinaryDeserializationSwitch.Enabled) 37 { 38 Trace.WriteLine( 39 "Deserializing the fields of 'DiagramEntityBase'."); 40 } 41 Initialize(); 36 string version = info.GetString("DiagramEntityBaseVersion"); 37 this.mName = info.GetString("Name"); 38 this.mSceneIndex = info.GetInt32("SceneIndex"); 39 this.mUid = new Guid(info.GetString("Uid")); 40 this.mResizable = info.GetBoolean("Resizable"); 42 41 43 string version = info.GetString("DiagramEntityBaseVersion"); 44 this.mName = info.GetString("Name"); 45 this.mSceneIndex = info.GetInt32("SceneIndex"); 46 this.mUid = new Guid(info.GetString("Uid")); 47 this.mResizable = info.GetBoolean("Resizable"); 42 this.mPaintStyle = info.GetValue( 43 "PaintStyle", 44 typeof(IPaintStyle)) as IPaintStyle; 48 45 49 this.mPaintStyle = info.GetValue(50 "PaintStyle",51 typeof(IPaintStyle)) as IPaintStyle;46 this.mPenStyle = info.GetValue( 47 "PenStyle", 48 typeof(IPenStyle)) as IPenStyle; 52 49 53 this.mPenStyle = info.GetValue( 54 "PenStyle", 55 typeof(IPenStyle)) as IPenStyle; 50 mAllowDelete = (bool)info.GetValue("AllowDelete", typeof(bool)); 51 myMinSize = (Size)info.GetValue("MinSize", typeof(Size)); 52 myMaxSize = (Size)info.GetValue("MaxSize", typeof(Size)); 53 mVisible = (bool)info.GetValue("Visible", typeof(bool)); 54 mEnabled = (bool)info.GetValue("Enabled", typeof(bool)); 55 } 56 #endregion 56 57 57 mAllowDelete = (bool)info.GetValue("AllowDelete", typeof(bool)); 58 myMinSize = (Size)info.GetValue("MinSize", typeof(Size)); 59 myMaxSize = (Size)info.GetValue("MaxSize", typeof(Size)); 60 mVisible = (bool)info.GetValue("Visible", typeof(bool)); 61 mEnabled = (bool)info.GetValue("Enabled", typeof(bool)); 62 } 63 #endregion 64 65 #region Serialization events 66 /* 58 #region Serialization events 59 /* 67 60 [OnSerializing] 68 61 void OnSerializing(StreamingContext context) … … 76 69 } 77 70 */ 78 71 #endregion 79 72 80 81 73 #region Deserialization events 74 /* 82 75 [OnDeserializing] 83 76 void OnDeserializing(StreamingContext context) … … 87 80 } 88 81 */ 89 [OnDeserialized] 90 void OnDeserialized(StreamingContext context) 91 { 92 if (Tracing.BinaryDeserializationSwitch.Enabled) 93 Trace.WriteLine("...deserialization of 'DiagramEntityBase' finished"); 94 } 82 [OnDeserialized] 83 void OnDeserialized(StreamingContext context) { 84 if (Tracing.BinaryDeserializationSwitch.Enabled) 85 Trace.WriteLine("...deserialization of 'DiagramEntityBase' finished"); 86 } 95 87 96 88 #endregion 97 89 98 90 #region Serialization 99 91 100 // ------------------------------------------------------------------ 101 /// <summary> 102 /// Populates a <see cref= 103 /// "T:System.Runtime.Serialization.SerializationInfo"></see> with 104 /// the data needed to serialize the target object. 105 /// </summary> 106 /// <param name="info">The 107 /// <see cref="T:System.Runtime.Serialization.SerializationInfo"></see> 108 /// to populate with data.</param> 109 /// <param name="context">The destination (see 110 /// <see cref="T:System.Runtime.Serialization.StreamingContext"></see>) 111 /// for this serialization.</param> 112 /// <exception cref="T:System.Security.SecurityException">The caller 113 /// does not have the required permission. </exception> 114 // ------------------------------------------------------------------ 115 public virtual void GetObjectData( 116 SerializationInfo info, 117 StreamingContext context) 118 { 119 if (Tracing.BinarySerializationSwitch.Enabled) 120 { 121 Trace.WriteLine("Serializing the fields of " + 122 "'DiagramEntityBase'."); 123 } 92 // ------------------------------------------------------------------ 93 /// <summary> 94 /// Populates a <see cref= 95 /// "T:System.Runtime.Serialization.SerializationInfo"></see> with 96 /// the data needed to serialize the target object. 97 /// </summary> 98 /// <param name="info">The 99 /// <see cref="T:System.Runtime.Serialization.SerializationInfo"></see> 100 /// to populate with data.</param> 101 /// <param name="context">The destination (see 102 /// <see cref="T:System.Runtime.Serialization.StreamingContext"></see>) 103 /// for this serialization.</param> 104 /// <exception cref="T:System.Security.SecurityException">The caller 105 /// does not have the required permission. </exception> 106 // ------------------------------------------------------------------ 107 public virtual void GetObjectData( 108 SerializationInfo info, 109 StreamingContext context) { 110 if (Tracing.BinarySerializationSwitch.Enabled) { 111 Trace.WriteLine("Serializing the fields of " + 112 "'DiagramEntityBase'."); 113 } 124 114 125 126 127 128 129 130 131 132 133 134 135 136 137 138 115 info.AddValue("DiagramEntityBaseVersion", diagramEntityBaseVersion); 116 info.AddValue("Name", this.Name); 117 info.AddValue("SceneIndex", this.SceneIndex); 118 info.AddValue("Uid", this.Uid.ToString()); 119 info.AddValue("Resizable", this.mResizable); 120 info.AddValue("PaintStyle", this.mPaintStyle, typeof(IPaintStyle)); 121 info.AddValue("PenStyle", this.mPenStyle, typeof(IPenStyle)); 122 info.AddValue("AllowDelete", mAllowDelete, typeof(bool)); 123 info.AddValue("MinSize", myMinSize, typeof(Size)); 124 info.AddValue("MaxSize", myMaxSize, typeof(Size)); 125 info.AddValue("Visible", mVisible, typeof(bool)); 126 info.AddValue("Enabled", mEnabled, typeof(bool)); 127 } 128 #endregion 139 129 140 #region Xml serialization 141 /// <summary> 142 /// This property is reserved, apply the <see cref="T:System.Xml.Serialization.XmlSchemaProviderAttribute"></see> to the class instead. 143 /// </summary> 144 /// <returns> 145 /// 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. 146 /// </returns> 147 public virtual XmlSchema GetSchema() 148 { 149 throw new NotImplementedException("The method or operation is not implemented."); 150 } 130 #region Xml serialization 131 /// <summary> 132 /// This property is reserved, apply the <see cref="T:System.Xml.Serialization.XmlSchemaProviderAttribute"></see> to the class instead. 133 /// </summary> 134 /// <returns> 135 /// 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. 136 /// </returns> 137 public virtual XmlSchema GetSchema() { 138 throw new NotImplementedException("The method or operation is not implemented."); 139 } 151 140 152 /// <summary> 153 /// Generates an object from its XML representation. 154 /// </summary> 155 /// <param name="reader">The <see cref="T:System.Xml.XmlReader"></see> stream from which the object is deserialized.</param> 156 public virtual void ReadXml(System.Xml.XmlReader reader) 157 { 158 throw new NotImplementedException("The method or operation is not implemented."); 159 } 141 /// <summary> 142 /// Generates an object from its XML representation. 143 /// </summary> 144 /// <param name="reader">The <see cref="T:System.Xml.XmlReader"></see> stream from which the object is deserialized.</param> 145 public virtual void ReadXml(System.Xml.XmlReader reader) { 146 throw new NotImplementedException("The method or operation is not implemented."); 147 } 160 148 161 /// <summary> 162 /// Converts an object into its XML representation. 163 /// </summary> 164 /// <param name="writer">The <see cref="T:System.Xml.XmlWriter"></see> stream to which the object is serialized.</param> 165 public virtual void WriteXml(System.Xml.XmlWriter writer) 166 { 167 throw new NotImplementedException("The method or operation is not implemented."); 168 } 169 #endregion 149 /// <summary> 150 /// Converts an object into its XML representation. 151 /// </summary> 152 /// <param name="writer">The <see cref="T:System.Xml.XmlWriter"></see> stream to which the object is serialized.</param> 153 public virtual void WriteXml(System.Xml.XmlWriter writer) { 154 throw new NotImplementedException("The method or operation is not implemented."); 155 } 156 #endregion 170 157 171 158 #region IDeserializationCallback Members 172 159 173 /// <summary> 174 /// Runs when the entire object graph has been deserialized. 175 /// </summary> 176 /// <param name="sender">The object that initiated the callback. The functionality for this parameter is not currently implemented.</param> 177 public virtual void OnDeserialization(object sender) 178 { 179 if (Tracing.BinaryDeserializationSwitch.Enabled) 180 Trace.WriteLine("IDeserializationCallback of 'DiagramEntityBase' called."); 181 UpdatePaintingMaterial(); 182 } 160 /// <summary> 161 /// Runs when the entire object graph has been deserialized. 162 /// </summary> 163 /// <param name="sender">The object that initiated the callback. The functionality for this parameter is not currently implemented.</param> 164 public virtual void OnDeserialization(object sender) { 165 if (Tracing.BinaryDeserializationSwitch.Enabled) 166 Trace.WriteLine("IDeserializationCallback of 'DiagramEntityBase' called."); 167 UpdatePaintingMaterial(); 168 } 183 169 184 185 170 #endregion 171 } 186 172 }
Note: See TracChangeset
for help on using the changeset viewer.