いもづる オブジェクト指向

MessageInfoLibクラス

 1|using System;
 2|using System.Collections;
 3|using System.Data;
 4|using System.Xml;
 5|
 6|namespace net.e_ioo.Common
 7|{
 8|    internal class MessageInfoLib
 9|    {
10|        private Hashtable _infoLib = new Hashtable();
11|
12|
13|        public MessageInfoLib(string infoFilePath)
14|        {
15|            this.LoadInfo(infoFilePath);
16|        }
17|
18|        private  void LoadInfo(string infoFilePath)
19|        {
20|            XmlDocument xmlDoc = new XmlDocument();
21|            xmlDoc.Load(infoFilePath);
22|
23|            XmlNodeReader xmlNodeReader = new XmlNodeReader(xmlDoc.SelectSingleNode("root"));
24|            DataSet ds = new DataSet();
25|            ds.ReadXml(xmlNodeReader);
26|
27|            string id = null;
28|            foreach(DataRow dataRow in ds.Tables[0].Rows){
29|                if(dataRow["id"] == null){ continue; }
30|                
31|                id = (string)dataRow["id"];
32|                if(id.Equals("")){ continue; }
33|
34|                this._infoLib.Add(id, new MessageInfo(id, 
35|                                                      ((string)dataRow["text"]).Replace("[CrLf]", "\r\n"),
36|                                                      (string)dataRow["icon"],
37|                                                      (string)dataRow["buttons"],
38|                                                      (string)dataRow["default"]
39|                                                     )
40|                                 );
41|            }
42|        }
43|
44|        public MessageInfo this[string id]
45|        {
46|            get{ return (MessageInfo)this._infoLib[id]; }
47|        }
48|
49|    }
50|}

 

webmaster@e-ioo.net