Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/IO/NML/xShapeType.cs @ 2769

Last change on this file since 2769 was 2769, checked in by mkommend, 14 years ago

added unused files for netron (ticket #867)

File size: 3.7 KB
Line 
1
2using System;
3using System.Xml;
4using System.Xml.Serialization;
5using System.IO;
6using System.Collections;
7   
8namespace Netron.GraphLib.IO.NML
9{   
10    /// <summary>
11    /// XML wrapper for a shape object
12    /// </summary>
13 
14  public class ShapeType : IXmlSerializable
15  {
16    #region Fields
17    /// <summary>
18    /// data collection
19    /// </summary>
20    private DataCollection mData = new DataCollection();
21    /// <summary>
22    /// the description
23    /// </summary>
24    private string mDescription;
25    /// <summary>
26    /// the mUID
27    /// </summary>
28    private string mUID;
29    /// <summary>
30    /// the unique key to the shape to be instantiated
31    /// </summary>
32    private string mInstanceKey = string.Empty;
33    #endregion
34
35    #region Properties
36        /// <summary>
37        /// Gets or sets the key to use when instantiating/deserializing the node again
38        /// </summary>
39   
40    public string InstanceKey
41    {
42      get{return mInstanceKey;}
43      set{mInstanceKey = value;}
44    }
45    /// <summary>
46    /// Gets or sets the description
47    /// </summary>
48 
49    public virtual string Desc
50    {
51      get
52      {
53        return this.mDescription;
54      }
55      set
56      {
57        this.mDescription = value;
58      }
59    }
60       
61    /// <summary>
62    /// Gets or sets the data collection
63    /// </summary>
64   
65    public virtual DataCollection Data
66    {
67      get
68      {
69        return this.mData;
70      }
71      set
72      {
73        this.mData = value;
74      }
75    }
76        /// <summary>
77        /// Gets or sets the mUID
78        /// </summary>
79 
80    public virtual string UID
81    {
82      get
83      {
84        return this.mUID;
85      }
86      set
87      {
88        this.mUID = value;
89      }
90    }
91    #endregion
92
93    #region IXmlSerializable Members
94
95    public void WriteXml(XmlWriter writer)
96    {
97      writer.WriteAttributeString("att","123");
98      writer.WriteComment("here it comes");
99      writer.WriteElementString("InstanceKey",this.mInstanceKey);
100      writer.WriteElementString("UID",this.mUID);
101      for(int k=0;k<mData.Count;k++)
102      {
103        if(typeof(ConnectorType).IsInstanceOfType(mData[k]))
104        {
105          writer.WriteStartElement("Connector");
106          writer.WriteAttributeString("UID", (mData[k] as ConnectorType).UID);
107          writer.WriteAttributeString("Name", (mData[k] as ConnectorType).Name);
108          writer.WriteEndElement();
109        }
110        else if(typeof(DataType).IsInstanceOfType(mData[k]))
111        {
112          writer.WriteStartElement("data");
113          writer.WriteAttributeString("key", (mData[k] as DataType).Key.ToString());         
114          if(typeof(DataCollection).IsInstanceOfType((mData[k] as DataType).Text))
115          {
116            WriteData(writer, (mData[k] as DataType).Text);           
117          }
118          else if(typeof(string).IsInstanceOfType((mData[k] as DataType).Text))
119            writer.WriteString((mData[k] as DataType).Text.ToString());
120       
121          writer.WriteEndElement();
122        }
123        else if(typeof(CollectionBase).IsInstanceOfType(mData[k]))
124        {
125          (mData[k] as IXmlSerializable).WriteXml(writer);
126        }
127     
128
129      }
130
131     
132    }
133
134
135    private void WriteData(XmlWriter writer,DataCollection collection)
136    {
137      for(int m=0; m<collection.Count; m++)
138      {
139        if(typeof(DataType).IsInstanceOfType(collection[m]))
140        {
141          writer.WriteStartElement("data");
142          writer.WriteAttributeString("key",(collection[m] as DataType).Key);
143          WriteData(writer,(collection[m] as DataType).Text);
144          writer.WriteEndElement();
145        }
146        else if(typeof(string).IsInstanceOfType(collection[m]))         
147          writer.WriteString(collection[m].ToString());
148      }
149    }
150
151    public System.Xml.Schema.XmlSchema GetSchema()
152    {
153      // TODO:  Add ShapeType.GetSchema implementation
154      return null;
155    }
156
157    public void ReadXml(XmlReader reader)
158    {
159      // TODO:  Add ShapeType.ReadXml implementation
160    }
161
162    #endregion
163  }
164}
165
Note: See TracBrowser for help on using the repository browser.