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

◆ GetTopLevelMapping()

static XmlTypeMapping System.Xml.Serialization.XmlReflectionImporter.GetTopLevelMapping ( Type type,
string defaultNamespace )
inlinestaticpackage

Definition at line 2266 of file XmlReflectionImporter.cs.

2267 {
2268 defaultNamespace = defaultNamespace ?? string.Empty;
2269 XmlAttributes xmlAttributes = new XmlAttributes(type);
2270 TypeDesc typeDesc = new TypeScope().GetTypeDesc(type);
2271 ElementAccessor elementAccessor = new ElementAccessor();
2272 if (typeDesc.Kind == TypeKind.Node)
2273 {
2274 elementAccessor.Any = true;
2275 }
2276 else
2277 {
2278 string @namespace = ((xmlAttributes.XmlRoot == null) ? defaultNamespace : xmlAttributes.XmlRoot.Namespace);
2279 string text = string.Empty;
2280 if (xmlAttributes.XmlType != null)
2281 {
2282 text = xmlAttributes.XmlType.TypeName;
2283 }
2284 if (text.Length == 0)
2285 {
2286 text = type.Name;
2287 }
2288 elementAccessor.Name = XmlConvert.EncodeLocalName(text);
2289 elementAccessor.Namespace = @namespace;
2290 }
2291 XmlTypeMapping xmlTypeMapping = new XmlTypeMapping(null, elementAccessor);
2292 xmlTypeMapping.SetKeyInternal(XmlMapping.GenerateKey(type, xmlAttributes.XmlRoot, defaultNamespace));
2293 return xmlTypeMapping;
2294 }

References System.Xml.Dictionary, System.Xml.XmlConvert.EncodeLocalName(), System.Xml.Serialization.XmlMapping.GenerateKey(), System.Xml.Serialization.TypeScope.GetTypeDesc(), System.text, and System.type.

Referenced by System.Xml.Serialization.XmlSerializer.XmlSerializer().