本文整理汇总了C#中System.Xml.Serialization.XmlTypeMapping.GetRealTypeMap方法的典型用法代码示例。如果您正苦于以下问题:C# XmlTypeMapping.GetRealTypeMap方法的具体用法?C# XmlTypeMapping.GetRealTypeMap怎么用?C# XmlTypeMapping.GetRealTypeMap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.Serialization.XmlTypeMapping
的用法示例。
在下文中一共展示了XmlTypeMapping.GetRealTypeMap方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteObject
protected virtual void WriteObject (XmlTypeMapping typeMap, object ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
{
if (ob == null)
{
if (isNullable)
{
if (_format == SerializationFormat.Literal) WriteNullTagLiteral(element, namesp);
else WriteNullTagEncoded (element, namesp);
}
return;
}
if (ob is XmlNode)
{
if (_format == SerializationFormat.Literal) WriteElementLiteral((XmlNode)ob, "", "", true, false);
else WriteElementEncoded((XmlNode)ob, "", "", true, false);
return;
}
if (typeMap.TypeData.SchemaType == SchemaTypes.XmlSerializable)
{
WriteSerializable ((IXmlSerializable)ob, element, namesp, isNullable);
return;
}
XmlTypeMapping map = typeMap.GetRealTypeMap (ob.GetType());
if (map == null)
{
// bug #81539
if (ob.GetType ().IsArray && typeof (XmlNode).IsAssignableFrom (ob.GetType ().GetElementType ())) {
Writer.WriteStartElement (element, namesp);
foreach (XmlNode node in (IEnumerable) ob)
node.WriteTo (Writer);
Writer.WriteEndElement ();
}
else
WriteTypedPrimitive (element, namesp, ob, true);
return;
}
if (writeWrappingElem)
{
if (map != typeMap || _format == SerializationFormat.Encoded) needType = true;
WriteStartElement (element, namesp, ob);
}
if (needType)
WriteXsiType(map.XmlType, map.XmlTypeNamespace);
switch (map.TypeData.SchemaType)
{
case SchemaTypes.Class: WriteObjectElement (map, ob, element, namesp); break;
case SchemaTypes.Array: WriteListElement (map, ob, element, namesp); break;
case SchemaTypes.Primitive: WritePrimitiveElement (map, ob, element, namesp); break;
case SchemaTypes.Enum: WriteEnumElement (map, ob, element, namesp); break;
}
if (writeWrappingElem)
WriteEndElement (ob);
}