Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
DataNode.cs
Go to the documentation of this file.
2
3internal class DataNode<T> : IDataNode
4{
5 protected Type dataType;
6
7 private T _value;
8
9 private string _dataContractName;
10
11 private string _dataContractNamespace;
12
13 private string _clrTypeName;
14
15 private string _clrAssemblyName;
16
17 private string _id = Globals.NewObjectId;
18
19 private bool _isFinalValue;
20
22
23 public object Value
24 {
25 get
26 {
27 return _value;
28 }
29 set
30 {
31 _value = (T)value;
32 }
33 }
34
36 {
37 get
38 {
39 return _isFinalValue;
40 }
41 set
42 {
44 }
45 }
46
47 public string DataContractName
48 {
49 get
50 {
51 return _dataContractName;
52 }
53 set
54 {
56 }
57 }
58
60 {
61 get
62 {
64 }
65 set
66 {
68 }
69 }
70
71 public string ClrTypeName
72 {
73 get
74 {
75 return _clrTypeName;
76 }
77 set
78 {
80 }
81 }
82
83 public string ClrAssemblyName
84 {
85 get
86 {
87 return _clrAssemblyName;
88 }
89 set
90 {
92 }
93 }
94
96
97 public string Id
98 {
99 get
100 {
101 return _id;
102 }
103 set
104 {
105 _id = value;
106 }
107 }
108
109 internal DataNode()
110 {
111 dataType = typeof(T);
112 _isFinalValue = true;
113 }
114
115 internal DataNode(T value)
116 : this()
117 {
118 _value = value;
119 }
120
121 public T GetValue()
122 {
123 return _value;
124 }
125
126 public virtual void GetData(ElementData element)
127 {
128 element.dataNode = this;
131 if (DataContractName != null)
132 {
133 AddQualifiedNameAttribute(element, "i", "type", "http://www.w3.org/2001/XMLSchema-instance", DataContractName, DataContractNamespace);
134 }
135 if (ClrTypeName != null)
136 {
137 element.AddAttribute("z", "http://schemas.microsoft.com/2003/10/Serialization/", "Type", ClrTypeName);
138 }
139 if (ClrAssemblyName != null)
140 {
141 element.AddAttribute("z", "http://schemas.microsoft.com/2003/10/Serialization/", "Assembly", ClrAssemblyName);
142 }
143 }
144
145 public virtual void Clear()
146 {
148 }
149
150 internal void AddQualifiedNameAttribute(ElementData element, string elementPrefix, string elementName, string elementNs, string valueName, string valueNs)
151 {
153 element.AddAttribute(elementPrefix, elementNs, elementName, prefix + ":" + valueName);
154 bool flag = false;
155 if (element.attributes != null)
156 {
157 for (int i = 0; i < element.attributes.Length; i++)
158 {
160 if (attributeData != null && attributeData.prefix == "xmlns" && attributeData.localName == prefix)
161 {
162 flag = true;
163 break;
164 }
165 }
166 }
167 if (!flag)
168 {
169 element.AddAttribute("xmlns", "http://www.w3.org/2000/xmlns/", prefix, valueNs);
170 }
171 }
172}
void AddQualifiedNameAttribute(ElementData element, string elementPrefix, string elementName, string elementNs, string valueName, string valueNs)
Definition DataNode.cs:150
virtual void GetData(ElementData element)
Definition DataNode.cs:126
void AddAttribute(string prefix, string ns, string name, string value)
static readonly string NewObjectId
Definition Globals.cs:172