易截截图软件、单文件、免安装、纯绿色、仅160KB

c# 支持XML序列化的泛型 Dictionary

/// <summary>
/// 支持XML序列化的泛型 Dictionary
/// </summary>
/// <typeparam name="TKey"></typeparam>
/// <typeparam name="TValue"></typeparam>
[XmlRoot("SerializableDictionary")]
public class SerializableDictionary<TKey, TValue>
: Dictionary<TKey, TValue>, IXmlSerializable
{
#region 构造函数
public SerializableDictionary()
: base()
{
}
public SerializableDictionary(IDictionary<TKey, TValue> dictionary)
: base(dictionary)
{
}
public SerializableDictionary(IEqualityComparer<TKey> comparer)
: base(comparer)
{
}
public SerializableDictionary(int capacity)
: base(capacity)
{
}
public SerializableDictionary(int capacity, IEqualityComparer<TKey> comparer)
: base(capacity, comparer)
{
}
protected SerializableDictionary(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
#endregion
#region IXmlSerializable Members
public System.Xml.Schema.XmlSchema GetSchema()
{
return null;
}
/// <summary>
/// 从对象的 XML 表示形式生成该对象
/// </summary>
/// <param name="reader"></param>
public void ReadXml(System.Xml.XmlReader reader)
{
XmlSerializer keySerializer = new XmlSerializer(typeof(TKey));
XmlSerializer valueSerializer = new XmlSerializer(typeof(TValue));
bool wasEmpty = reader.IsEmptyElement;
reader.Read();
if (wasEmpty)
return;
while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
{
reader.ReadStartElement("item");
rea


相关文档:

XML Schema帮助文档3

XML Schema attributeGroup 元素
定义和用法
attributeGroup 元素用于对属性声明进行组合,这样这些声明就能够以组合的形式合并到复杂类型中。
元素信息
出现次数
无限制
父元素
attributeGroup、complexType、schema、restriction (simpleContent)、extension (simpleContent)、rest ......

xml shema帮助文档5

XML Schema union 元素
定义和用法
union 元素定义多个 simpleType 定义的集合。
元素信息
出现次数
一次
父元素
simpleType
内容
annotation、simpleType
语法
<union
id=ID
memberTypes="list of QNames"
any attributes
>
(annotation?,(simpleType ......

as3操作xml之二

范例如下:
var xml:XML=
         <body>
             text1
             <bar>barText1</bar>
    & ......

C#序列化与反序列化Xml,利用范型做通用化处理

public class yzzSerialize
{
private yzzSerialize()
{ }
private static yzzCache cache = new yzzCache();
public static T GetfromXml<T>(string xmlpath, T t)
{
using (FileStream fs = new FileStream(xmlpath, FileMode.Open, FileAcces ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号