Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ WriteArray()

void System.Xml.Serialization.XmlSerializationWriter.WriteArray ( string name,
string ns,
object o,
Type type )
inlineprivate

Definition at line 1310 of file XmlSerializationWriter.cs.

1311 {
1312 Type arrayElementType = TypeScope.GetArrayElementType(type, null);
1314 if (!_soap12)
1315 {
1317 {
1318 arrayElementType = TypeScope.GetArrayElementType(arrayElementType, null);
1319 stringBuilder.Append("[]");
1320 }
1321 }
1322 string text;
1323 string ns2;
1324 if (arrayElementType == typeof(object))
1325 {
1326 text = "anyType";
1327 ns2 = "http://www.w3.org/2001/XMLSchema";
1328 }
1329 else
1330 {
1332 if (typeEntry != null)
1333 {
1334 text = typeEntry.typeName;
1335 ns2 = typeEntry.typeNs;
1336 }
1337 else if (_soap12)
1338 {
1340 if (primitiveTypeName != null)
1341 {
1342 text = primitiveTypeName.Name;
1343 ns2 = primitiveTypeName.Namespace;
1344 }
1345 else
1346 {
1347 Type baseType = arrayElementType.BaseType;
1348 while (baseType != null)
1349 {
1351 if (typeEntry != null)
1352 {
1353 break;
1354 }
1355 baseType = baseType.BaseType;
1356 }
1357 if (typeEntry != null)
1358 {
1359 text = typeEntry.typeName;
1360 ns2 = typeEntry.typeNs;
1361 }
1362 else
1363 {
1364 text = "anyType";
1365 ns2 = "http://www.w3.org/2001/XMLSchema";
1366 }
1367 }
1368 }
1369 else
1370 {
1372 text = primitiveTypeName2.Name;
1373 ns2 = primitiveTypeName2.Namespace;
1374 }
1375 }
1376 if (stringBuilder.Length > 0)
1377 {
1378 text += stringBuilder.ToString();
1379 }
1380 if (_soap12 && name != null && name.Length > 0)
1381 {
1382 WriteStartElement(name, ns, null, writePrefixed: false);
1383 }
1384 else
1385 {
1386 WriteStartElement("Array", "http://schemas.xmlsoap.org/soap/encoding/", null, writePrefixed: true);
1387 }
1389 if (type.IsArray)
1390 {
1391 Array array = (Array)o;
1392 int length = array.Length;
1393 if (_soap12)
1394 {
1395 _w.WriteAttributeString("itemType", "http://www.w3.org/2003/05/soap-encoding", GetQualifiedName(text, ns2));
1396 _w.WriteAttributeString("arraySize", "http://www.w3.org/2003/05/soap-encoding", length.ToString(CultureInfo.InvariantCulture));
1397 }
1398 else
1399 {
1400 _w.WriteAttributeString("arrayType", "http://schemas.xmlsoap.org/soap/encoding/", $"{GetQualifiedName(text, ns2)}[{length}]");
1401 }
1402 for (int i = 0; i < length; i++)
1403 {
1405 }
1406 }
1407 else
1408 {
1409 int num = (typeof(ICollection).IsAssignableFrom(type) ? ((ICollection)o).Count : (-1));
1410 if (_soap12)
1411 {
1412 _w.WriteAttributeString("itemType", "http://www.w3.org/2003/05/soap-encoding", GetQualifiedName(text, ns2));
1413 if (num >= 0)
1414 {
1415 _w.WriteAttributeString("arraySize", "http://www.w3.org/2003/05/soap-encoding", num.ToString(CultureInfo.InvariantCulture));
1416 }
1417 }
1418 else
1419 {
1420 string text2 = ((num >= 0) ? ("[" + num + "]") : "[]");
1421 _w.WriteAttributeString("arrayType", "http://schemas.xmlsoap.org/soap/encoding/", GetQualifiedName(text, ns2) + text2);
1422 }
1424 if (enumerator != null)
1425 {
1426 while (enumerator.MoveNext())
1427 {
1429 }
1430 }
1431 }
1433 }
static CultureInfo InvariantCulture
void WritePotentiallyReferencingElement(string? n, string? ns, object? o)
void WriteAttributeString(string localName, string? ns, string? value)
Definition XmlWriter.cs:46

References System.Xml.Serialization.XmlSerializationWriter._soap12, System.Xml.Serialization.XmlSerializationWriter._w, System.array, System.Xml.Serialization.Array, System.Xml.Dictionary, System.Xml.Serialization.TypeScope.GetArrayElementType(), System.Collections.Generic.Dictionary< TKey, TValue >.GetEnumerator(), System.Xml.Serialization.XmlSerializationWriter.GetPrimitiveTypeName(), System.Xml.Serialization.XmlSerializationWriter.GetQualifiedName(), System.Xml.Serialization.XmlSerializationWriter.GetTypeEntry(), System.Globalization.CultureInfo.InvariantCulture, System.length, System.text, System.type, System.Xml.XmlWriter.WriteAttributeString(), System.Xml.XmlWriter.WriteEndElement(), System.Xml.Serialization.XmlSerializationWriter.WriteId(), System.Xml.Serialization.XmlSerializationWriter.WritePotentiallyReferencingElement(), and System.Xml.Serialization.XmlSerializationWriter.WriteStartElement().

Referenced by System.Xml.Serialization.XmlSerializationWriter.WriteReferencedElement().