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

◆ ImportElement()

ElementAccessor System.Xml.Serialization.XmlReflectionImporter.ImportElement ( TypeModel model,
XmlRootAttribute root,
string defaultNamespace,
RecursionLimiter limiter )
inlineprivate

Definition at line 231 of file XmlReflectionImporter.cs.

232 {
233 XmlAttributes attributes = GetAttributes(model.Type, canBeSimpleType: true);
234 if (root == null)
235 {
236 root = attributes.XmlRoot;
237 }
238 string text = root?.Namespace;
239 if (text == null)
240 {
241 text = defaultNamespace;
242 }
243 if (text == null)
244 {
246 }
250 ElementAccessor elementAccessor = CreateElementAccessor(ImportTypeMapping(model, text, ImportContext.Element, string.Empty, attributes, limiter), text);
251 if (root != null)
252 {
253 if (root.ElementName.Length > 0)
254 {
255 elementAccessor.Name = XmlConvert.EncodeLocalName(root.ElementName);
256 }
257 if (root.GetIsNullableSpecified() && !root.IsNullable && model.TypeDesc.IsOptionalValue)
258 {
259 throw new InvalidOperationException(System.SR.Format(System.SR.XmlInvalidNotNullable, model.TypeDesc.BaseTypeDesc.FullName, "XmlRoot"));
260 }
261 elementAccessor.IsNullable = (root.GetIsNullableSpecified() ? root.IsNullable : (model.TypeDesc.IsNullable || model.TypeDesc.IsOptionalValue));
262 CheckNullable(elementAccessor.IsNullable, model.TypeDesc, elementAccessor.Mapping);
263 }
264 else
265 {
266 elementAccessor.IsNullable = model.TypeDesc.IsNullable || model.TypeDesc.IsOptionalValue;
267 }
269 return (ElementAccessor)ReconcileAccessor(elementAccessor, _elements);
270 }
static string XmlInvalidNotNullable
Definition SR.cs:1476
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
Definition SR.cs:7
static void CheckNullable(bool isNullable, TypeDesc typeDesc, TypeMapping mapping)
static ElementAccessor CreateElementAccessor(TypeMapping mapping, string ns)
Accessor ReconcileAccessor(Accessor accessor, NameTable accessors)
XmlAttributes GetAttributes(Type type, bool canBeSimpleType)

References System.Xml.Serialization.XmlReflectionImporter._arrayNestingLevel, System.Xml.Serialization.XmlReflectionImporter._defaultNs, System.Xml.Serialization.XmlReflectionImporter._elements, System.Xml.Serialization.XmlReflectionImporter._savedArrayItemAttributes, System.Xml.Serialization.XmlReflectionImporter._savedArrayNamespace, System.Xml.Serialization.XmlReflectionImporter.CheckNullable(), System.Xml.Serialization.XmlReflectionImporter.CreateElementAccessor(), System.Xml.Dictionary, System.Xml.Serialization.XmlRootAttribute.ElementName, System.Xml.XmlConvert.EncodeLocalName(), System.SR.Format(), System.Xml.Serialization.XmlReflectionImporter.GetAttributes(), System.Xml.Serialization.XmlRootAttribute.GetIsNullableSpecified(), System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(), System.Xml.Serialization.XmlRootAttribute.IsNullable, System.Xml.Serialization.XmlRootAttribute.Namespace, System.Xml.Serialization.XmlReflectionImporter.ReconcileAccessor(), System.text, System.SR.XmlInvalidNotNullable, and System.Xml.Serialization.XmlAttributes.XmlRoot.

Referenced by System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping().