示例#1
0
        public void ReadXml(XmlReader reader)
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(reader);

            if (xmlDoc != null)
            {
                string culturestr = xmlDoc.DocumentElement.GetAttribute("Culture");
                if (!string.IsNullOrEmpty(culturestr))
                {
                    Culture = ResourceHelper.CultureTypeFromString(culturestr);
                }

                XmlNodeList nodes = xmlDoc.DocumentElement.SelectNodes("//root/data");
                if (nodes != null && nodes.Count > 0)
                {
                    XmlElement nameElm;
                    XmlElement valueElm;
                    foreach (XmlElement elm in nodes)
                    {
                        nameElm = elm.SelectSingleNode("name") as XmlElement;
                        if (nameElm != null)
                        {
                            valueElm = elm.SelectSingleNode("value") as XmlElement;
                            if (valueElm != null)
                            {
                                if (!ResourceDatas.ContainsKey(nameElm.InnerText))
                                {
                                    ResourceDatas.Add(nameElm.InnerText, valueElm.InnerText);
                                }
                            }
                        }
                    }
                }
            }
        }