本文整理汇总了C#中System.Xml.Serialization.XmlTypeMapping.TypeName属性的典型用法代码示例。如果您正苦于以下问题:C# XmlTypeMapping.TypeName属性的具体用法?C# XmlTypeMapping.TypeName怎么用?C# XmlTypeMapping.TypeName使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.Xml.Serialization.XmlTypeMapping
的用法示例。
在下文中一共展示了XmlTypeMapping.TypeName属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
//引入命名空间
using System;
using System.IO;
using System.Xml.Serialization;
using System.Collections;
using System.Xml;
using System.Text;
namespace Company{
[SoapType("TheGroup", "http://www.cohowinery.com")]
public class Group
{
public string GroupName;
public Thing[] Things;
[SoapElement(DataType = "language")]
public string Lang = "en";
[SoapElement(DataType = "integer")]
public string MyNumber;
[SoapElement(DataType = "duration")]
public string ReDate = "8/31/01";
}
public class Thing{
public string ThingName;
}
public class Test
{
public static void Main()
{
Test t = new Test();
t.GetMap("MyMap.xml");
}
public void GetMap(string filename){
// Create an XmlSerializer instance.
XmlTypeMapping map = new SoapReflectionImporter().ImportTypeMapping(typeof(Group));
Console.WriteLine("ElementName: " + map.ElementName);
Console.WriteLine("Namespace: " + map.Namespace);
Console.WriteLine("TypeFullName: " + map.TypeFullName);
Console.WriteLine("TypeName: " + map.TypeName);
XmlSerializer ser = new XmlSerializer(map);
Group xGroup= new Group();
xGroup.GroupName= "MyCar";
xGroup.MyNumber= 5454.ToString();
xGroup.Things = new Thing[]{new Thing(), new Thing()};
// To write the outer wrapper, use an XmlTextWriter.
XmlTextWriter writer =
new XmlTextWriter(filename, Encoding.UTF8);
writer.Formatting = Formatting.Indented;
writer.WriteStartElement("wrapper");
ser.Serialize(writer, xGroup);
writer.WriteEndElement();
writer.Close();
}
}
}