那里。我有以下类定义:
[Serializable]
public enum FilterType
{
[XmlEnum("1")]
Text = 1,
[XmlEnum("2")]
Date = 2,
[XmlEnum("3")]
Combo = 3,
[XmlEnum("4")]
Multichoice = 4
}
public class FilterValues : List<string>
{
public FilterType Type { get; set; }
}
[Serializable]
public struct SerializableKeyValuePair<K, V>
{
public SerializableKeyValuePair(KeyValuePair<K, V> p)
{
this.key = p.Key;
this.value = p.Value;
}
private K key;
public K Key
{
get { return key; }
set { key = value; }
}
private V value;
public V Value
{
get { return this.value; }
set { this.value = value; }
}
}
SerializableKeyValuePair<string, FilterValues>[]
当我尝试使用字符串类型的键和 FilterValues ( )类型的值序列化 SerializableKeyValuePair 数组时,我无法序列化 xml 中的 Type 属性。我得到了这个结果:
<?xml version="1.0" encoding="utf-16"?>
<ArrayOfSerializableKeyValuePairOfStringFilterValues xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SerializableKeyValuePairOfStringFilterValues>
<Key>Date</Key>
<Value> <string>2012-5-16</string> </Value>
</SerializableKeyValuePairOfStringFilterValues>
<SerializableKeyValuePairOfStringFilterValues>
<Key>bgName</Key> <Value> <string>4</string> </Value>
</SerializableKeyValuePairOfStringFilterValues>
</ArrayOfSerializableKeyValuePairOfStringFilterValues>
请帮忙,我尝试了任何可能的方法。