点击下载 Resources.rar

/// <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 = ; 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 = ; 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();
}
}
}

[XML] Resource帮助类的更多相关文章

  1. 8 -- 深入使用Spring -- 3...1 Resource实现类ServletContextResource

    8.3.1 Resource实现类------ServletContextResource:访问相对于ServletContext路径下的资源的实现类. 4.访问应用相关资源 Spring提供了Ser ...

  2. 8 -- 深入使用Spring -- 3...1 Resource实现类FileSystemResource

    8.3.1 Resource实现类------FileSystemResource:访问文件系统的资源的实现类 3.访问文件系统资源 Spring提供的FileSystemResource类用于访问文 ...

  3. 8 -- 深入使用Spring -- 3...1 Resource实现类ClassPathResource

    8.3.1 Resource实现类------ClassPathResource : 访问类加载路径下的资源的实现类 2.访问类加载路径下的资源 ClassPathResource 用来访问类加载路径 ...

  4. 8 -- 深入使用Spring -- 3...1 Resource实现类UrlResource

    8.3.1 Resource 实现类------UrlResource : 访问网络资源的实现类 1.访问网络资源 访问网络资源通过UrlResource 类实现,UrlResource是java.n ...

  5. 阶段3 1.Mybatis_03.自定义Mybatis框架_4.自定义mybatis的编码-解析XML的工具类介绍

    导入xml操作的类和用到的相关包 创建util包,然后把提供好的XMLConfigBuilder.java文件复制3过来 复制过来,里面用到了很多dom4j的东西 打开pom.xml 输入depend ...

  6. 让Visual Studio 2013为你自动生成XML反序列化的类

    Visual Sutdio 2013增加了许多新功能,其中很多都直接提高了对代码编辑的便利性.如: 1. 在代码编辑界面的右侧滚动条上显示不同颜色的标签,让开发人员可以对所编辑文档的修改.查找.定位情 ...

  7. XML格式示例 与 XML操作(读取)类封装

    header('Content-Type: text/xml'); <?xml version="1.0" encoding="utf-8" standa ...

  8. c# XML和实体类之间相互转换(序列化和反序列化)[砖]

    link: http://blog.okbase.net/haobao/archive/62.html by: 好饱 我们需要在XML与实体类,DataTable,List之间进行转换,下面是XmlU ...

  9. C# XML和实体类之间相互转换(序列化和反序列化)

    我们需要在XML与实体类,DataTable,List之间进行转换,下面是XmlUtil类,该类来自网络并稍加修改. using System; using System.Collections.Ge ...

随机推荐

  1. linux系统目录详解

    Linux目录结构包括文件类型和一些重要的文件子目录. linux文件系统的最顶端是/,称为linux的root,所有的目录.文件.设备都在/之下.文件类型linux有四种基本文件系统类型:普通文件. ...

  2. 在linux系统下怎么安装两个nginx

    在linux下安装nginx的时候,一般在./configure的阶段会要求通过prefix设置安装路径.因此,在./configure的时候指定不同的prefix就可以安装多个nginx啦. 值得注 ...

  3. C#获取文件的当前路径

    C#获取文件的当前路径 1. System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName -获取模块的完整路径. 2.Syst ...

  4. sql server 清除日志

    SQL2008 的收缩日志  由于SQL2008对文件和日志管理进行了优化,所以以下语句在SQL2005中可以运行但在SQL2008中已经被取消: (SQL2005) Backup Log DNNam ...

  5. 新浪微博授权时出现"关注 *** 的微博"

    基本设置完成后, 保证scope是 "all" 或 至少 包含 "follow_app_official_microblog". 测试时, 保证你的测试账号没有 ...

  6. calabash-android Win10 入门笔记

    参考官方文档:https://developer.xamarin.com/guides/testcloud/calabash/   概述     Calabash是一个BDD的UI自动化验收测试框架, ...

  7. ARM学习笔记8——通用寄存器和存储器内容交换指令和软中断指令

    交换指令将一个存储单元内容与制定的寄存器内容相交换,交换指令为进程间同步提供了一种方便的解决途径.该指令产生一堆原子Load/Store操作,该操作发生在一个连续的总线操作中,在操作期间阻止其他任何指 ...

  8. java的IO学习,字节流与字符流的编码讲解

    字节流与字符流 字节流可以处理所有类型的数据(图片.视频等),在java中对应的类都为“stream”结尾 1字节=8位二进制=具体存储空间   字符流仅能处理纯文本的数据,在java中对应的类都是以 ...

  9. 转载:monkeyrunner工具

    前言: 最近开始研究Android自动化测试方法,对其中的一些工具.方法和框架做了一些简单的整理,其中包括 android测试框架.CTS.Monkey.Monkeyrunner.benchmark. ...

  10. Java Apcahe的HTTPClient工具Http请求当请求超时重发

    java Apcahe的HTTPClient工具Http请求当请求超时时底层会默认进行重发,默认重发次数为3次,在某些情况下为了防止重复的请求,需要将自动重发覆盖. 设置HTTP参数,设置不进行自动重 ...