惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Cisco Talos Blog
Cisco Talos Blog
阮一峰的网络日志
阮一峰的网络日志
云风的 BLOG
云风的 BLOG
D
Docker
Vercel News
Vercel News
IT之家
IT之家
Recent Announcements
Recent Announcements
Last Week in AI
Last Week in AI
V
Visual Studio Blog
Engineering at Meta
Engineering at Meta
腾讯CDC
Google DeepMind News
Google DeepMind News
I
InfoQ
博客园 - 三生石上(FineUI控件)
Apple Machine Learning Research
Apple Machine Learning Research
The GitHub Blog
The GitHub Blog
博客园 - Franky
The Cloudflare Blog
A
About on SuperTechFans
有赞技术团队
有赞技术团队
Y
Y Combinator Blog
T
Tenable Blog
P
Proofpoint News Feed
Recorded Future
Recorded Future
Security Latest
Security Latest
H
Hackread – Cybersecurity News, Data Breaches, AI and More
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
博客园 - 聂微东
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Google Online Security Blog
Google Online Security Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Simon Willison's Weblog
Simon Willison's Weblog
The Last Watchdog
The Last Watchdog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
N
News and Events Feed by Topic
TaoSecurity Blog
TaoSecurity Blog
U
Unit 42
The Hacker News
The Hacker News
Martin Fowler
Martin Fowler
T
Threat Research - Cisco Blogs
NISL@THU
NISL@THU
F
Full Disclosure
M
MIT News - Artificial intelligence
人人都是产品经理
人人都是产品经理
Hugging Face - Blog
Hugging Face - Blog
V
V2EX
Project Zero
Project Zero

博客园 - 油纸伞

假如m是奇数,且m>=3,证明m(m² -1)能被8整除 SharpSvn操作 -- 获取Commit节点列表 GetRelativePath获取相对路径 Winform中Checkbox与其他集合列表类型之间进行关联 Image(支持 XML 序列化),注意C#中原生的Image类是无法进行Xml序列化的 修复使用<code>XmlDocument</code>加载含有DOCTYPE的Xml时,加载后增加“[]”字符的错误 使用序列化来Clone对象 [转]PowerDesigner15生成Hibernate 用户自定义类型的隐式转换 Net3.5及以上版本INotifyPropertyChanged接口的友好用法 知识加油站 知识加油站 Top K算法详细解析 C#值类型和引用类型 Oracle分区技术 对Oracle表分区的一点认识 oracle创建分区表 数据库大表的优化:采用蔟表(clustered tables)及蔟索引(Clustered Index) 2008年.Net编程人员工具参照
Dictionary(支持 XML 序列化),注意C#中原生的Dictionary类是无法进行Xml序列化的
油纸伞 · 2017-04-19 · via 博客园 - 油纸伞

 1     /// <summary>
 2     /// Dictionary(支持 XML 序列化)
 3     /// </summary>
 4     /// <typeparam name="TKey">键类型</typeparam>
 5     /// <typeparam name="TValue">值类型</typeparam>
 6     [XmlRoot("XmlDictionary")]
 7     [Serializable]
 8     public class XmlDictionary<TKey, TValue> : Dictionary<TKey, TValue>, IXmlSerializable
 9     {
10         #region 构造函数
11         public XmlDictionary()
12         { }
13 
14         public XmlDictionary(IDictionary<TKey, TValue> dictionary) : base(dictionary)
15         { }
16 
17         public XmlDictionary(IEqualityComparer<TKey> comparer) : base(comparer)
18         { }
19 
20         public XmlDictionary(int capacity) : base(capacity)
21         { }
22 
23         public XmlDictionary(int capacity, IEqualityComparer<TKey> comparer) : base(capacity, comparer)
24         { }
25 
26         protected XmlDictionary(SerializationInfo info, StreamingContext context) : base(info, context)
27         { }
28         #endregion 构造函数
29 
30         #region IXmlSerializable Members
31         public XmlSchema GetSchema() => null;
32 
33         /// <summary>
34         ///     从对象的 XML 表示形式生成该对象(反序列化)
35         /// </summary>
36         /// <param name="xr"></param>
37         public void ReadXml(XmlReader xr)
38         {
39             if (xr.IsEmptyElement)
40                 return;
41             var ks = new XmlSerializer(typeof(TKey));
42             var vs = new XmlSerializer(typeof(TValue));
43             xr.Read();
44             while (xr.NodeType != XmlNodeType.EndElement)
45             {
46                 xr.ReadStartElement("Item");
47                 xr.ReadStartElement("Key");
48                 var key = (TKey)ks.Deserialize(xr);
49                 xr.ReadEndElement();
50                 xr.ReadStartElement("Value");
51                 var value = (TValue)vs.Deserialize(xr);
52                 xr.ReadEndElement();
53                 Add(key, value);
54                 xr.ReadEndElement();
55                 xr.MoveToContent();
56             }
57             xr.ReadEndElement();
58         }
59 
60         /// <summary>
61         ///     将对象转换为其 XML 表示形式(序列化)
62         /// </summary>
63         /// <param name="xw"></param>
64         public void WriteXml(XmlWriter xw)
65         {
66             var ks = new XmlSerializer(typeof(TKey));
67             var vs = new XmlSerializer(typeof(TValue));
68             foreach (var key in Keys)
69             {
70                 xw.WriteStartElement("Item");
71                 xw.WriteStartElement("Key");
72                 ks.Serialize(xw, key);
73                 xw.WriteEndElement();
74                 xw.WriteStartElement("Value");
75                 vs.Serialize(xw, this[key]);
76                 xw.WriteEndElement();
77                 xw.WriteEndElement();
78             }
79         }
80         #endregion IXmlSerializable Members
81     }

View Code