Ste*_*ger 7 c# xml vb.net xml-serialization xmlserializer
问题:我在http://weblogs.asp.net/pwelter34/archive/2006/05/03/444961.aspx上使用可序列化的字典类 来序列化字典.哪个工作正常,但我遇到了一个恼人的问题.
<System.Xml.Serialization.XmlRoot("DataBase")> _
Public Class cDataBase
<System.Xml.Serialization.XmlNamespaceDeclarations()> _
Public ns As New System.Xml.Serialization.XmlSerializerNamespaces()
<System.Xml.Serialization.XmlElement("Tables")> _
Public Tables1 As New SerializableDictionary(Of String, cTable)
End Class ' cDataBase
Run Code Online (Sandbox Code Playgroud)
当我序列化上述类的实例时,创建的xml如下所示:
<Tables>
<item>
<key>
<string>MyTable</string>
</key>
<value>
<Table CreationDate="0001-01-01T00:00:00" LastModified="0001-01-01T00:00:00">
<Columns>
<Column Name="PrimaryKeyName">
<DataType>Uniqueidentifier</DataType>
<Length>36</Length>
</Column>
</Columns>
<Rows>
<Row>
<Item>Reihe1</Item>
<Item>Reihe2</Item>
<Item>Reihe3</Item>
</Row>
<Row>
<Item>Reihe1</Item>
<Item>Reihe2</Item>
<Item>Reihe3</Item>
</Row>
Run Code Online (Sandbox Code Playgroud)
如果我能弄清楚如何将键从<string>重命名为属性中定义的内容,那将会很好
<key>
<string>MyTable</string>
</key>
Run Code Online (Sandbox Code Playgroud)
基本上类似于XmlArrayItem属性,如下面,if(仅)字典是一个数组...
<System.Xml.Serialization.XmlArray("Tables")> _
<System.Xml.Serialization.XmlArrayItem("Table")> _
Public Tables As New List(Of cTable)
Run Code Online (Sandbox Code Playgroud)
我想尝试将字符串更改为从字符串继承的自定义类,我可以配备一个名称,但问题是,不能从字符串继承...
| 归档时间: |
|
| 查看次数: |
2610 次 |
| 最近记录: |