Пример #1
0
        /// <summary>
        /// Gets a specific List of resources as a list of ResxItems.
        /// This list only retrieves items for a specific locale. No
        /// resource normalization occurs.
        /// </summary>
        /// <param name="FileName"></param>
        /// <returns></returns>
        internal List <ResxItem> GetResXResources(string FileName)
        {
            string FilePath = Path.GetDirectoryName(FileName) + "\\";

            XmlDocument Dom = new XmlDocument();

            try
            {
                Dom.Load(FileName);
            }
            catch (Exception ex)
            {
                this.ErrorMessage = ex.Message;
                return(null);
            }

            List <ResxItem> resxItems = new List <ResxItem>();

            XmlNodeList nodes = Dom.DocumentElement.SelectNodes("data");

            foreach (XmlNode Node in nodes)
            {
                string Value = null;

                XmlNodeList valueNodes = Node.SelectNodes("value");
                if (valueNodes.Count == 1)
                {
                    Value = valueNodes[0].InnerText;
                }
                else
                {
                    Value = Node.InnerText;
                }

                string Name = Node.Attributes["name"].Value;
                string Type = null;
                if (Node.Attributes["type"] != null)
                {
                    Type = Node.Attributes["type"].Value;
                }

                ResxItem resxItem = new ResxItem()
                {
                    Name = Name, Type = Type, Value = Value
                };
                resxItems.Add(resxItem);
            }
            return(resxItems);
        }
    /// <summary>
    /// Gets a specific List of resources as a list of ResxItems.
    /// This list only retrieves items for a specific locale. No
    /// resource normalization occurs.
    /// </summary>
    /// <param name="FileName"></param>
    /// <returns></returns>
    internal List<ResxItem> GetResXResources(string FileName)
    {
        string FilePath = Path.GetDirectoryName(FileName) + "\\";

        XmlDocument Dom = new XmlDocument();

        try
        {
            Dom.Load(FileName);
        }
        catch (Exception ex)
        {
            ErrorMessage = ex.Message;
            return null;
        }

        List<ResxItem> resxItems = new List<ResxItem>();
        
        XmlNodeList nodes = Dom.DocumentElement.SelectNodes("data");

        foreach (XmlNode Node in nodes)
        {
            string Value = null;

            XmlNodeList valueNodes = Node.SelectNodes("value");
            if (valueNodes.Count == 1)
                Value = valueNodes[0].InnerText;
            else
                Value = Node.InnerText;

            string Name = Node.Attributes["name"].Value;
            string Type = null;
            if (Node.Attributes["type"] != null)
                Type = Node.Attributes["type"].Value;

            ResxItem resxItem = new ResxItem { Name = Name, Type = Type, Value = Value };
            resxItems.Add(resxItem);
        }
        return resxItems;
    }