Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
XmlObjectSerializerReadContextComplexJson.cs
Go to the documentation of this file.
3using System.Text;
4using System.Xml;
5
7
9{
11
13
14 private readonly bool _useSimpleDictionaryFormat;
15
17
19
28
33
34 [RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")]
36 {
38 }
39
40 [RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")]
42 {
43 int num = memberNames.Length;
44 if (num != 0)
45 {
46 int num2 = 0;
47 int num3 = (memberIndex + 1) % num;
48 while (num2 < num)
49 {
51 {
52 return num3;
53 }
54 num2++;
55 num3 = (num3 + 1) % num;
56 }
58 {
59 int num4 = 0;
60 int num5 = (memberIndex + 1) % num;
61 while (num4 < num)
62 {
63 if (memberNames[num5].Value == name)
64 {
65 return num5;
66 }
67 num4++;
68 num5 = (num5 + 1) % num;
69 }
70 }
71 }
73 return num;
74 }
75
77 {
78 _extensionDataValueType = xmlReader.GetAttribute("type");
79 }
80
82 {
83 IDataNode result;
85 {
86 case null:
87 case "string":
88 result = new DataNode<string>(xmlReader.ReadContentAsString());
89 break;
90 case "boolean":
91 result = new DataNode<bool>(xmlReader.ReadContentAsBoolean());
92 break;
93 case "number":
95 break;
96 default:
98 }
99 xmlReader.ReadEndElement();
100 return result;
101 }
102
123
124 internal override int GetArraySize()
125 {
126 return -1;
127 }
128
130 {
131 if (attributes == null)
132 {
133 attributes = new Attributes();
134 }
136 if (xmlReader.MoveToAttribute("type") && xmlReader.Value == "null")
137 {
138 attributes.XsiNil = true;
139 }
140 else if (xmlReader.MoveToAttribute("__type"))
141 {
144 string text = xmlQualifiedName.Namespace;
145 if (!string.IsNullOrEmpty(text))
146 {
147 switch (text[0])
148 {
149 case '#':
150 text = "http://schemas.datacontract.org/2004/07/" + text.AsSpan(1);
151 break;
152 case '\\':
153 if (text.Length >= 2)
154 {
155 char c = text[1];
156 if (c == '#' || c == '\\')
157 {
158 text = text.Substring(1);
159 }
160 }
161 break;
162 }
163 }
165 }
166 xmlReader.MoveToElement();
167 }
168
169 internal string TrimNamespace(string serverTypeNamespace)
170 {
171 if (!string.IsNullOrEmpty(serverTypeNamespace))
172 {
173 switch (serverTypeNamespace[0])
174 {
175 case '#':
176 serverTypeNamespace = "http://schemas.datacontract.org/2004/07/" + serverTypeNamespace.AsSpan(1);
177 break;
178 case '\\':
179 if (serverTypeNamespace.Length >= 2)
180 {
181 char c = serverTypeNamespace[1];
182 if (c == '#' || c == '\\')
183 {
185 }
186 }
187 break;
188 }
189 }
190 return serverTypeNamespace;
191 }
192
193 internal static XmlQualifiedName ParseQualifiedName(string qname)
194 {
195 string name;
196 string ns;
197 if (string.IsNullOrEmpty(qname))
198 {
199 name = (ns = string.Empty);
200 }
201 else
202 {
203 qname = qname.Trim();
204 int num = qname.IndexOf(':');
205 if (num >= 0)
206 {
207 name = qname.Substring(0, num);
208 ns = qname.Substring(num + 1);
209 }
210 else
211 {
212 name = qname;
213 ns = string.Empty;
214 }
215 }
216 return new XmlQualifiedName(name, ns);
217 }
218
220 {
221 return xmlReader.GetAttribute("type") == "array";
222 }
223
225 {
226 return xmlReader.GetAttribute("type") == "object";
227 }
228
233
234 [RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")]
241
242 [RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")]
249
250 [RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")]
257
258 internal static bool TryGetJsonLocalName(XmlReaderDelegator xmlReader, [NotNullWhen(true)] out string name)
259 {
260 if (xmlReader.IsStartElement(JsonGlobals.itemDictionaryString, JsonGlobals.itemDictionaryString) && xmlReader.MoveToAttribute("item"))
261 {
262 name = xmlReader.Value;
263 return true;
264 }
265 name = null;
266 return false;
267 }
268
270 {
272 {
273 return xmlReader.LocalName;
274 }
275 return name;
276 }
277
282
284 {
286 int num = 0;
287 for (int i = 0; i < memberNames.Length; i++)
288 {
290 {
291 if (stringBuilder.Length != 0)
292 {
293 stringBuilder.Append(", ");
294 }
295 stringBuilder.Append(memberNames[i]);
296 num++;
297 }
298 }
299 if (num == 1)
300 {
302 }
304 }
305
306 private static bool IsBitSet(byte[] bytes, int bitIndex)
307 {
309 }
310
311 [RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")]
316}
static bool IsBitSet(byte[] bytes, int bitIndex)
static string GetClrTypeFullName(Type type)
static object ReadJsonValue(DataContract contract, XmlReaderDelegator reader, XmlObjectSerializerReadContextComplexJson context)
static readonly XmlDictionaryString itemDictionaryString
static object ParseJsonNumber(string value, out TypeCode objectTypeCode)
static XmlQualifiedName ParseQualifiedName(string qname)
static void ThrowMissingRequiredMembers(object obj, XmlDictionaryString[] memberNames, byte[] expectedElements, byte[] requiredElements)
XmlObjectSerializerReadContextComplexJson(DataContractJsonSerializer serializer, DataContract rootTypeDataContract)
static bool TryGetJsonLocalName(XmlReaderDelegator xmlReader, [NotNullWhen(true)] out string name)
override DataContract GetDataContractSkipValidation(int typeId, RuntimeTypeHandle typeHandle, Type type)
int GetJsonMemberIndex(XmlReaderDelegator xmlReader, XmlDictionaryString[] memberNames, int memberIndex, ExtensionDataObject extensionData)
static XmlObjectSerializerReadContextComplexJson CreateContext(DataContractJsonSerializer serializer, DataContract rootTypeDataContract)
override object ReadDataContractValue(DataContract dataContract, XmlReaderDelegator reader)
override IDataNode ReadPrimitiveExtensionDataValue(XmlReaderDelegator xmlReader, string dataContractName, string dataContractNamespace)
static void ThrowDuplicateMemberException(object obj, XmlDictionaryString[] memberNames, int memberIndex)
static DataContract ResolveJsonDataContractFromRootDataContract(XmlObjectSerializerContext context, XmlQualifiedName typeQName, DataContract rootTypeDataContract)
void HandleMemberNotFound(XmlReaderDelegator xmlReader, ExtensionDataObject extensionData, int memberIndex)
static SerializationException CreateSerializationException(string errorMessage)
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string JsonOneRequiredMemberNotFound
Definition SR.cs:626
static string ParseJsonNumberReturnInvalidNumber
Definition SR.cs:678
static string JsonRequiredMembersNotFound
Definition SR.cs:624
static string JsonDuplicateMemberInInput
Definition SR.cs:622
static string JsonUnexpectedAttributeValue
Definition SR.cs:534
Definition SR.cs:7
static XmlDictionaryString Empty
TypeCode
Definition TypeCode.cs:4