當前位置: 首頁>>代碼示例>>VB.NET>>正文


VB.NET XmlTypeMapping.XsdTypeNamespace屬性代碼示例

本文整理匯總了VB.NET中System.Xml.Serialization.XmlTypeMapping.XsdTypeNamespace屬性的典型用法代碼示例。如果您正苦於以下問題:VB.NET XmlTypeMapping.XsdTypeNamespace屬性的具體用法?VB.NET XmlTypeMapping.XsdTypeNamespace怎麽用?VB.NET XmlTypeMapping.XsdTypeNamespace使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在System.Xml.Serialization.XmlTypeMapping的用法示例。


在下文中一共展示了XmlTypeMapping.XsdTypeNamespace屬性的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。

示例1: Things

' 導入命名空間
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.XsdTypeNamespace


注:本文中的System.Xml.Serialization.XmlTypeMapping.XsdTypeNamespace屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。