只需一步,快速开始
分布式系统框架(V2.0) 轻松承载百亿数据,千万流量!讨论专区 - 源码下载 - 官方教程
HttpHelper爬虫框架(V2.7-含.netcore) HttpHelper官方出品,爬虫框架讨论区 - 源码下载 - 在线测试和代码生成
HttpHelper爬虫类(V2.0) 开源的爬虫类,支持多种模式和属性 源码 - 代码生成器 - 讨论区 - 教程- 例子
/// <summary> /// 类说明:Resources /// 编 码 人:苏飞 /// 联系方式:361983679 /// 更新网站:[url=http://www.sufeinet.com/thread-655-1-1.html]http://www.sufeinet.com/thread-655-1-1.html[/url] /// </summary> using System; using System.Collections.Generic; using System.Xml; using System.Xml.Serialization; namespace DotNet.Utilities { /// <summary> /// BUResourceManager /// 资源管理器 /// </author> /// </summary> [XmlRoot("resources")] public class Resources { private SortedList<String, String> indexs = new SortedList<String, String>(); [XmlElement("language")] public string language = string.Empty; [XmlElement("displayName")] public string displayName = string.Empty; [XmlElement("version")] public string version = string.Empty; [XmlElement("author")] public string author = string.Empty; [XmlElement("description")] public string description = string.Empty; [XmlElement("items", typeof(Items))] public Items items; public void createIndex() { indexs.Clear(); if (items == null) { return; } indexs = new SortedList<String, String>(items.items.Length); for (int i = 0; i < items.items.Length; i++) { #if DEBUG try { [i] indexs.Add(items.items.key, items.items.value); } catch { throw (new Exception(items.items.key + items.items.value)); } #else indexs.Add(items.items.key, items.items.value); #endif } } public string Get(string key) { if (!indexs.ContainsKey(key)) { return string.Empty; } return indexs[key]; } /// <summary> /// JiRiGaLa 2007.05.02 /// </summary> /// <param name="key"></param> /// <param name="value"></param> /// <returns></returns> public bool Set(string key, string value) { if (!indexs.ContainsKey(key)) { return false; } indexs[key] = value; for (int i = 0; i < items.items.Length; i++) { if (items.items.key == key) { items.items.value = value; break; } } return true; } } public class Items { [XmlElement("item", typeof(Item))] public Item[] items; } public class Item { [XmlAttribute("key")] public string key = string.Empty; [XmlText] public string value = string.Empty; } internal class ResourcesSerializer { public static Resources DeSerialize(string filePath) { System.Xml.Serialization.XmlSerializer XmlSerializer = new System.Xml.Serialization.XmlSerializer(typeof(Resources)); System.IO.FileStream FileStream = new System.IO.FileStream(filePath, System.IO.FileMode.Open); Resources Resources = XmlSerializer.Deserialize(FileStream) as Resources; FileStream.Close(); return Resources; } public static void Serialize(string filePath, Resources Resources) { System.Xml.Serialization.XmlSerializer XmlSerializer = new System.Xml.Serialization.XmlSerializer(typeof(Resources)); System.IO.FileStream FileStream = new System.IO.FileStream(filePath, System.IO.FileMode.Create); XmlSerializer.Serialize(FileStream, Resources); FileStream.Close(); } } }
使用道具 举报
本版积分规则 发表回复 回帖后跳转到最后一页
|手机版|小黑屋|手机版|联系我们|关于我们|广告合作|苏飞论坛 ( 豫ICP备18043678号-2)
GMT+8, 2024-11-21 21:47
© 2014-2021