本文整理汇总了C#中System.Xml.Serialization.XmlSerializerNamespaces.XmlSerializerNamespaces构造函数的典型用法代码示例。如果您正苦于以下问题:C# XmlSerializerNamespaces构造函数的具体用法?C# XmlSerializerNamespaces怎么用?C# XmlSerializerNamespaces使用的例子?那么恭喜您, 这里精选的构造函数代码示例或许可以为您提供帮助。您也可以进一步了解该构造函数所在类System.Xml.Serialization.XmlSerializerNamespaces
的用法示例。
在下文中一共展示了XmlSerializerNamespaces构造函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateBook
private void CreateBook(string filename)
{
try
{
// Create instance of XmlSerializerNamespaces and add the namespaces.
XmlSerializerNamespaces myNameSpaces = new XmlSerializerNamespaces();
myNameSpaces.Add("BookName", "http://www.cpandl.com");
// Create instance of XmlSerializer and specify the type of object
// to be serialized.
XmlSerializer mySerializerObject =
new XmlSerializer(typeof(MyBook));
TextWriter myWriter = new StreamWriter(filename);
// Create object to be serialized.
MyBook myXMLBook = new MyBook();
myXMLBook.Author = "XMLAuthor";
myXMLBook.BookName = "DIG THE XML";
myXMLBook.Description = "This is a XML Book";
MyPriceClass myBookPrice = new MyPriceClass();
myBookPrice.Price = (decimal) 45.89;
myBookPrice.Units = "$";
myXMLBook.BookPrice = myBookPrice;
// Serialize the object.
mySerializerObject.Serialize(myWriter, myXMLBook,myNameSpaces);
myWriter.Close();
}
catch(Exception e)
{
Console.WriteLine("Exception :" + e.Message + "Occurred");
}
}
示例2: CreateFromQNames
private XmlSerializerNamespaces CreateFromQNames()
{
XmlQualifiedName q1 =
new XmlQualifiedName("money", "http://www.cohowinery.com");
XmlQualifiedName q2 =
new XmlQualifiedName("books", "http://www.cpandl.com");
XmlQualifiedName[] names = {q1, q2};
return new XmlSerializerNamespaces(names);
}