2013年7月20日

序列化和反序列化

摘要: 代码:internal static class Class1{ private static readonly string XML_FOLDER = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "CompanyName", "ProjectName"); private static readonly string XML_FILE = Path.Combine(XML_FOLDER, "config.xml" 阅读全文

posted @ 2013-07-20 21:50 yao2yao4 阅读(208) 评论(0) 推荐(0) 编辑

获取任意可序列化对象的Xml字符串,方便在日志中查看任一所感兴趣的对象。

摘要: 代码:public static string GetLoggingString(this object obj){ using (var stream = new MemoryStream()) { new XmlSerializer(obj.GetType()).Serialize(stream, obj); stream.Position = 0; var buffer = new byte[stream.Length]; stream.ReadAsync(buffer, 0, buffer.Length); ... 阅读全文

posted @ 2013-07-20 20:33 yao2yao4 阅读(246) 评论(0) 推荐(0) 编辑

导航