Ejemplo n.º 1
0
        /// <summary>
        /// Parses the WixLocalization element.
        /// </summary>
        /// <param name="node">Element to parse.</param>
        private void ParseWixLocalizationElement(XmlNode node)
        {
            int    codepage = -1;
            string culture  = null;
            SourceLineNumberCollection sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);

            foreach (XmlAttribute attrib in node.Attributes)
            {
                if (0 == attrib.NamespaceURI.Length || attrib.NamespaceURI == Localization.XmlNamespaceUri)
                {
                    switch (attrib.LocalName)
                    {
                    case "Codepage":
                        codepage = Common.GetValidCodePage(attrib.Value, true);
                        break;

                    case "Culture":
                        culture = attrib.Value;
                        break;

                    default:
                        throw new WixException(WixErrors.UnexpectedAttribute(sourceLineNumbers, attrib.OwnerElement.Name, attrib.Name));
                    }
                }
                else
                {
                    Common.UnsupportedExtensionAttribute(sourceLineNumbers, attrib, Localization.OnMessage);
                }
            }

            this.codepage = codepage;
            this.culture  = String.IsNullOrEmpty(culture) ? String.Empty : culture.ToLower(CultureInfo.InvariantCulture);

            foreach (XmlNode child in node.ChildNodes)
            {
                if (XmlNodeType.Element == child.NodeType)
                {
                    if (child.NamespaceURI == Localization.XmlNamespaceUri)
                    {
                        switch (child.LocalName)
                        {
                        case "String":
                            this.ParseString(child);
                            break;

                        case "UI":
                            this.ParseUI(child);
                            break;

                        default:
                            throw new WixException(WixErrors.UnexpectedElement(sourceLineNumbers, node.Name, child.Name));
                        }
                    }
                    else
                    {
                        throw new WixException(WixErrors.UnsupportedExtensionElement(sourceLineNumbers, node.Name, child.Name));
                    }
                }
            }
        }