当前位置: 首页>>代码示例>>VB.NET>>正文


VB.NET XmlTypeMapping.TypeName属性代码示例

本文整理汇总了VB.NET中System.Xml.Serialization.XmlTypeMapping.TypeName属性的典型用法代码示例。如果您正苦于以下问题:VB.NET XmlTypeMapping.TypeName属性的具体用法?VB.NET XmlTypeMapping.TypeName怎么用?VB.NET XmlTypeMapping.TypeName使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在System.Xml.Serialization.XmlTypeMapping的用法示例。


在下文中一共展示了XmlTypeMapping.TypeName属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。

示例1: Group

' 导入命名空间
Imports System.IO
Imports System.Xml.Serialization
Imports System.Collections
Imports System.Xml
Imports System.Text


Namespace Company
    
<SoapType("TheGroup", "http://www.cohowinery.com")> _
Public Class Group

   ' The SoapElementAttribute specifies that the
   ' generated XML element name will be "Wheels"
   ' instead of "Vehicle".
   Public GroupName As String 
   public Things() As  Thing
   <SoapElement(DataType:= "language")> _
   Public Lang As String = "en"
   <SoapElement(DataType:= "integer")> _
   Public MyNumber As String 

   <SoapElement(DataType:= "duration")> _
   Public ReDate As String  = "8/31/01"
End Class

Public Class Thing 
   Public ThingName As String 
End Class

Public Class Test
   Shared Sub Main()
   
      Dim t As Test = new Test()

      t.GetMap("MyMap.xml")
   End Sub


   public Sub GetMap(filename As string )
      ' Create an XmlSerializer instance.
      Dim map As XmlTypeMapping = new SoapReflectionImporter().ImportTypeMapping(GetType(Group))
      Console.WriteLine("ElementName: " + map.ElementName)
      Console.WriteLine("Namespace: " + map.Namespace)
      Console.WriteLine("TypeFullName: " + map.TypeFullName)
      Console.WriteLine("TypeName: " + map.TypeName)
      Dim ser As XmlSerializer= new XmlSerializer(map)
      Dim xGroup As Group =  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.
      Dim writer As XmlTextWriter =  _
      new XmlTextWriter(filename, Encoding.UTF8)
      writer.Formatting = Formatting.Indented
      writer.WriteStartElement("wrapper")
      ser.Serialize(writer, xGroup)
      writer.WriteEndElement()
      writer.Close()
   End Sub
End Class

End namespace
开发者ID:VB.NET开发者,项目名称:System.Xml.Serialization,代码行数:64,代码来源:XmlTypeMapping.TypeName


注:本文中的System.Xml.Serialization.XmlTypeMapping.TypeName属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。