Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
SerializableMapping.cs
Go to the documentation of this file.
4using System.Text;
6
8
9internal sealed class SerializableMapping : SpecialMapping
10{
12
14 private Type _type;
15
16 private bool _needSchema = true;
17
18 private readonly MethodInfo _getSchemaMethod;
19
21
23
25
26 private bool _any;
27
28 private string _namespaces;
29
31
33
35
37
38 internal bool IsAny
39 {
40 get
41 {
42 if (_any)
43 {
44 return true;
45 }
46 if (_getSchemaMethod == null)
47 {
48 return false;
49 }
51 {
52 return false;
53 }
55 return _any;
56 }
57 }
58
59 internal string NamespaceList
60 {
61 get
62 {
64 if (_namespaces == null)
65 {
66 if (_schemas != null)
67 {
69 foreach (XmlSchema item in _schemas.Schemas())
70 {
71 if (item.TargetNamespace != null && item.TargetNamespace.Length > 0)
72 {
73 if (stringBuilder.Length > 0)
74 {
75 stringBuilder.Append(' ');
76 }
77 stringBuilder.Append(item.TargetNamespace);
78 }
79 }
80 _namespaces = stringBuilder.ToString();
81 }
82 else
83 {
84 _namespaces = string.Empty;
85 }
86 }
87 return _namespaces;
88 }
89 }
90
92
94
96 {
97 get
98 {
99 return _next;
100 }
101 set
102 {
103 _next = value;
104 }
105 }
106
108 internal Type Type
109 {
110 get
111 {
112 return _type;
113 }
114 set
115 {
116 _type = value;
117 }
118 }
119
121 {
122 get
123 {
125 return _schemas;
126 }
127 }
128
129 internal XmlSchema Schema
130 {
131 get
132 {
134 return _schema;
135 }
136 }
137
139 {
140 get
141 {
142 if (!_needSchema)
143 {
144 return _xsiType;
145 }
146 if (_getSchemaMethod == null)
147 {
148 return null;
149 }
150 if (typeof(XmlSchemaType).IsAssignableFrom(_getSchemaMethod.ReturnType))
151 {
152 return null;
153 }
155 return _xsiType;
156 }
157 }
158
160 {
161 get
162 {
164 return _xsdType;
165 }
166 }
167
169 {
170 }
171
173 {
175 _any = any;
176 base.Namespace = ns;
178 }
179
181 {
183 _schemas = schemas;
184 base.TypeName = xsiType.Name;
185 base.Namespace = xsiType.Namespace;
186 _needSchema = false;
187 }
188
190 {
192 if (_baseMapping != null)
193 {
196 if (this == _nextDerivedMapping)
197 {
199 }
200 }
201 }
202
203 internal static void ValidationCallbackWithErrorCode(object sender, ValidationEventArgs args)
204 {
205 if (args.Severity == XmlSeverityType.Error)
206 {
207 throw new InvalidOperationException(System.SR.Format(System.SR.XmlSerializableSchemaError, "IXmlSerializable", args.Message));
208 }
209 }
210
211 internal void CheckDuplicateElement(XmlSchemaElement element, string elementNs)
212 {
213 if (element == null || element.Parent == null || !(element.Parent is XmlSchema))
214 {
215 return;
216 }
218 if (Schema != null && Schema.TargetNamespace == elementNs)
219 {
220 XmlSchemas.Preprocess(Schema);
221 xmlSchemaObjectTable = Schema.Elements;
222 }
223 else
224 {
225 if (Schemas == null)
226 {
227 return;
228 }
230 }
232 {
233 if (value.Name == element.Name && value.QualifiedName.Namespace == elementNs)
234 {
235 if (Match(value, element))
236 {
237 break;
238 }
240 }
241 }
242 }
243
245 {
246 if (e1.IsNillable != e2.IsNillable)
247 {
248 return false;
249 }
250 if (e1.RefName != e2.RefName)
251 {
252 return false;
253 }
254 if (e1.SchemaType != e2.SchemaType)
255 {
256 return false;
257 }
258 if (e1.SchemaTypeName != e2.SchemaTypeName)
259 {
260 return false;
261 }
262 if (e1.MinOccurs != e2.MinOccurs)
263 {
264 return false;
265 }
266 if (e1.MaxOccurs != e2.MaxOccurs)
267 {
268 return false;
269 }
270 if (e1.IsAbstract != e2.IsAbstract)
271 {
272 return false;
273 }
274 if (e1.DefaultValue != e2.DefaultValue)
275 {
276 return false;
277 }
278 if (e1.SubstitutionGroup != e2.SubstitutionGroup)
279 {
280 return false;
281 }
282 return true;
283 }
284
286 {
287 if (!_needSchema)
288 {
289 return;
290 }
291 _needSchema = false;
292 if (_getSchemaMethod != null)
293 {
294 if (_schemas == null)
295 {
296 _schemas = new XmlSchemaSet();
297 }
298 object obj = _getSchemaMethod.Invoke(null, new object[1] { _schemas });
300 if (obj != null)
301 {
302 if (typeof(XmlSchemaType).IsAssignableFrom(_getSchemaMethod.ReturnType))
303 {
306 }
307 else
308 {
309 if (!typeof(XmlQualifiedName).IsAssignableFrom(_getSchemaMethod.ReturnType))
310 {
312 }
314 if (_xsiType.IsEmpty)
315 {
317 }
318 }
319 }
320 else
321 {
322 _any = true;
323 }
326 if (!_xsiType.IsEmpty && _xsiType.Namespace != "http://www.w3.org/2001/XMLSchema")
327 {
329 if (arrayList.Count == 0)
330 {
332 }
333 if (arrayList.Count > 1)
334 {
336 }
338 if (xmlSchema == null)
339 {
341 }
343 if (_xsdType == null)
344 {
346 }
348 }
349 }
350 else
351 {
353 _schema = xmlSerializable.GetSchema();
354 if (_schema != null && (_schema.Id == null || _schema.Id.Length == 0))
355 {
357 }
358 }
359 }
360}
static ? object CreateInstance([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors|DynamicallyAccessedMemberTypes.NonPublicConstructors)] Type type, BindingFlags bindingAttr, Binder? binder, object?[]? args, CultureInfo? culture)
Definition Activator.cs:17
object? Invoke(object? obj, object?[]? parameters)
static string XmlSerializableRootDupName
Definition SR.cs:1790
static string XmlSerializableNameMissing1
Definition SR.cs:1408
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string XmlCircularDerivation
Definition SR.cs:1772
static string XmlGetSchemaTypeMissing
Definition SR.cs:1760
static string XmlGetSchemaInclude
Definition SR.cs:1762
static string XmlGetSchemaEmptyTypeName
Definition SR.cs:1758
static string XmlMissingSchema
Definition SR.cs:1618
static string XmlSerializableSchemaError
Definition SR.cs:1750
static string XmlGetSchemaMethodReturnType
Definition SR.cs:1756
Definition SR.cs:7
string? FullName
Definition Type.cs:47
XmlSchemaObjectTable GlobalElements
bool Match(XmlSchemaElement e1, XmlSchemaElement e2)
static void ValidationCallbackWithErrorCode(object sender, ValidationEventArgs args)
SerializableMapping(MethodInfo getSchemaMethod, bool any, string ns)
void SetBaseMapping(SerializableMapping mapping)
SerializableMapping(XmlQualifiedName xsiType, XmlSchemaSet schemas)
void CheckDuplicateElement(XmlSchemaElement element, string elementNs)
static void Preprocess(XmlSchema schema)
static readonly XmlQualifiedName Empty