Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
XmlObjectSerializerContext.cs
Go to the documentation of this file.
3using System.Xml;
4
6
8{
10
12
14
16
18
20
21 private int _itemCount;
22
23 private readonly int _maxItemsInObjectGraph;
24
26
27 private readonly bool _ignoreExtensionDataObject;
28
30
32
33 internal virtual SerializationMode Mode => SerializationMode.SharedContract;
34
35 internal virtual bool IsGetOnlyCollection
36 {
37 get
38 {
39 return false;
40 }
41 set
42 {
43 }
44 }
45
47
49
51
53 {
54 get
55 {
56 if (_knownTypeResolver == null)
57 {
59 }
60 return _knownTypeResolver;
61 }
62 }
63
65 {
66 [RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")]
67 get
68 {
70 {
73 }
75 }
76 }
77
87
92
99
101 {
102 return _streamingContext;
103 }
104
113
114 [RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")]
116 {
117 return GetDataContract(type.TypeHandle, type);
118 }
119
120 [RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")]
129
130 [RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")]
139
140 [RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")]
142 {
144 {
146 }
147 return DataContract.GetDataContract(id, typeHandle, Mode);
148 }
149
150 [RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")]
158
159 [RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")]
160 internal virtual Type GetSurrogatedType(Type type)
161 {
162 return type;
163 }
164
165 [RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")]
167 {
169 if (dictionary == null)
170 {
171 return null;
172 }
173 if (!dictionary.TryGetValue(qname, out var value))
174 {
175 return null;
176 }
177 return value;
178 }
179
180 [RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")]
182 {
183 if (knownTypeList == null)
184 {
185 return null;
186 }
189 for (int i = 0; i < knownTypeList.Count; i++)
190 {
191 Type type = knownTypeList[i];
192 if (type == null)
193 {
195 }
197 }
199 }
200
201 [RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")]
203 {
204 bool flag = false;
205 if (knownDataContracts != null)
206 {
207 scopedKnownTypes.Push(knownDataContracts);
208 flag = true;
209 }
210 bool result = IsKnownType(dataContract, declaredType);
211 if (flag)
212 {
214 }
215 return result;
216 }
217
218 [RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")]
220 {
222 if (dataContract2 != null)
223 {
224 return dataContract2.UnderlyingType == dataContract.UnderlyingType;
225 }
226 return false;
227 }
228
229 [RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")]
234
235 [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.")]
252 {
253 XmlQualifiedName xmlQualifiedName = new XmlQualifiedName(typeName, typeNs);
255 if (_dataContractResolver == null)
256 {
258 }
259 else
260 {
262 dataContract = ((type == null) ? null : GetDataContract(type));
263 }
264 if (dataContract == null)
265 {
266 if (memberTypeContract != null && !memberTypeContract.UnderlyingType.IsInterface && memberTypeContract.StableName == xmlQualifiedName)
267 {
269 }
270 if (dataContract == null && rootTypeDataContract != null)
271 {
273 }
274 }
275 return dataContract;
276 }
277
278 [RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")]
293
294 [RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")]
296 {
297 if (dc != null && dc.KnownDataContracts != null)
298 {
299 scopedKnownTypes.Push(dc.KnownDataContracts);
300 }
301 }
302
303 [RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")]
305 {
306 if (dc != null && dc.KnownDataContracts != null)
307 {
309 }
310 }
311}
Type? ResolveName(string typeName, string? typeNamespace, Type? declaredType, DataContractResolver knownTypeResolver)
static void CheckAndAdd(Type type, Dictionary< Type, Type > typesChecked, [NotNullIfNotNull("nameToDataContractTable")] ref Dictionary< XmlQualifiedName, DataContract > nameToDataContractTable)
static int GetId(RuntimeTypeHandle typeHandle)
static DataContract GetDataContract(Type type)
static DataContract GetDataContractSkipValidation(int id, RuntimeTypeHandle typeHandle, Type type)
static DataContract GetGetOnlyCollectionDataContractSkipValidation(int id, RuntimeTypeHandle typeHandle, Type type)
static DataContract GetGetOnlyCollectionDataContract(int id, RuntimeTypeHandle typeHandle, Type type, SerializationMode mode)
static PrimitiveDataContract GetPrimitiveDataContract(Type type)
DataContract ResolveDataContractFromKnownTypes(string typeName, string typeNs, DataContract memberTypeContract, Type declaredType)
virtual DataContract GetDataContractSkipValidation(int typeId, RuntimeTypeHandle typeHandle, Type type)
XmlObjectSerializerContext(DataContractSerializer serializer, DataContract rootTypeDataContract, DataContractResolver dataContractResolver)
bool IsKnownType(DataContract dataContract, Dictionary< XmlQualifiedName, DataContract > knownDataContracts, Type declaredType)
virtual DataContract ResolveDataContractFromRootDataContract(XmlQualifiedName typeQName)
virtual DataContract GetDataContract(int id, RuntimeTypeHandle typeHandle)
XmlObjectSerializerContext(XmlObjectSerializer serializer, int maxItemsInObjectGraph, StreamingContext streamingContext, bool ignoreExtensionDataObject)
DataContract ResolveDataContractFromKnownTypes(XmlQualifiedName typeName)
DataContract GetDataContractFromSerializerKnownTypes(XmlQualifiedName qname)
XmlObjectSerializerContext(XmlObjectSerializer serializer, int maxItemsInObjectGraph, StreamingContext streamingContext, bool ignoreExtensionDataObject, DataContractResolver dataContractResolver)
static Dictionary< XmlQualifiedName, DataContract > GetDataContractsForKnownTypes(IList< Type > knownTypeList)
virtual DataContract GetDataContract(RuntimeTypeHandle typeHandle, Type type)
virtual void CheckIfTypeSerializable(Type memberType, bool isMemberTypeSerializable)
virtual Dictionary< XmlQualifiedName, DataContract > SerializerKnownDataContracts
Dictionary< XmlQualifiedName, DataContract > serializerKnownDataContracts
bool IsKnownType(DataContract dataContract, Type declaredType)
static SerializationException CreateSerializationException(string errorMessage)
virtual ? Dictionary< XmlQualifiedName, DataContract > KnownDataContracts
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string ExceededMaxItemsQuota
Definition SR.cs:102
static string TypeNotSerializable
Definition SR.cs:286
static string NullKnownType
Definition SR.cs:220
Definition SR.cs:7
void Push(Dictionary< XmlQualifiedName, DataContract > dataContractDictionary)
DataContract GetDataContract(XmlQualifiedName qname)