Пример #1
0
        /// <summary>
        /// Parses a web error element.
        /// </summary>
        /// <param name="node">Element to parse.</param>
        /// <param name="parentType">Type of the parent.</param>
        /// <param name="parent">Id of the parent.</param>
        private void ParseWebErrorElement(XmlNode node, WebErrorParentType parentType, string parent)
        {
            SourceLineNumberCollection sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
            int errorCode = CompilerCore.IntegerNotSet;
            string file = null;
            string url = null;
            int subCode = CompilerCore.IntegerNotSet;

            foreach (XmlAttribute attrib in node.Attributes)
            {
                if (0 == attrib.NamespaceURI.Length || attrib.NamespaceURI == this.schema.TargetNamespace)
                {
                    switch (attrib.LocalName)
                    {
                        case "ErrorCode":
                            errorCode = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 400, 599);
                            break;
                        case "File":
                            file = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
                            break;
                        case "SubCode":
                            subCode = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, int.MaxValue);
                            break;
                        case "URL":
                            url = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
                            break;
                        default:
                            this.Core.UnexpectedAttribute(sourceLineNumbers, attrib);
                            break;
                    }
                }
                else
                {
                    this.Core.UnsupportedExtensionAttribute(sourceLineNumbers, attrib);
                }
            }

            if (CompilerCore.IntegerNotSet == errorCode)
            {
                this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name, "ErrorCode"));
                errorCode = CompilerCore.IllegalInteger;
            }

            if (CompilerCore.IntegerNotSet == subCode)
            {
                this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name, "SubCode"));
                subCode = CompilerCore.IllegalInteger;
            }

            if (String.IsNullOrEmpty(file) && String.IsNullOrEmpty(url))
            {
                this.Core.OnMessage(WixErrors.IllegalAttributeWithOtherAttribute(sourceLineNumbers, node.Name, "File", "URL"));
            }

            foreach (XmlNode child in node.ChildNodes)
            {
                if (XmlNodeType.Element == child.NodeType)
                {
                    if (child.NamespaceURI == this.schema.TargetNamespace)
                    {
                        this.Core.UnexpectedElement(node, child);
                    }
                    else
                    {
                        this.Core.UnsupportedExtensionElement(node, child);
                    }
                }
            }

            // Reference ConfigureIIs since nothing will happen without it
            this.Core.CreateWixSimpleReferenceRow(sourceLineNumbers, "CustomAction", "ConfigureIIs");

            if (!this.Core.EncounteredError)
            {
                Row row = this.Core.CreateRow(sourceLineNumbers, "IIsWebError");
                row[0] = errorCode;
                row[1] = subCode;
                row[2] = (int)parentType;
                row[3] = parent;
                row[4] = file;
                row[5] = url;
            }
        }
Пример #2
0
        /// <summary>
        /// Parses a web error element.
        /// </summary>
        /// <param name="node">Element to parse.</param>
        /// <param name="parentType">Type of the parent.</param>
        /// <param name="parent">Id of the parent.</param>
        private void ParseWebErrorElement(XmlNode node, WebErrorParentType parentType, string parent)
        {
            SourceLineNumberCollection sourceLineNumbers = this.core.GetSourceLineNumbers(node);
            int errorCode = CompilerCore.IntegerNotSet;
            string file = null;
            string url = null;
            int subCode = CompilerCore.IntegerNotSet;

            foreach (XmlAttribute attrib in node.Attributes)
            {
                switch (attrib.LocalName)
                {
                    case "ErrorCode":
                        errorCode = this.core.GetAttributeIntegerValue(sourceLineNumbers, attrib);
                        break;
                    case "File":
                        file = this.core.GetAttributeValue(sourceLineNumbers, attrib);
                        break;
                    case "SubCode":
                        subCode = this.core.GetAttributeIntegerValue(sourceLineNumbers, attrib);
                        break;
                    case "URL":
                        url = this.core.GetAttributeValue(sourceLineNumbers, attrib);
                        break;
                    default:
                        this.core.UnexpectedAttribute(sourceLineNumbers, attrib);
                        break;
                }
            }

            if (CompilerCore.IntegerNotSet == errorCode)
            {
                this.core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name, "ErrorCode"));
                errorCode = CompilerCore.IllegalInteger;
            }
            if (CompilerCore.IntegerNotSet == subCode)
            {
                this.core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name, "SubCode"));
                subCode = CompilerCore.IllegalInteger;
            }
            if (400 > errorCode || 599 < errorCode)
            {
                this.core.OnMessage(WixErrors.IllegalAttributeValue(sourceLineNumbers, node.Name, "ErrorCode", errorCode.ToString()));
                errorCode = CompilerCore.IllegalInteger;
            }
            if (null != file && null != url)
            {
                this.core.OnMessage(WixErrors.IllegalAttributeWithOtherAttribute(sourceLineNumbers, node.Name, "File", "URL"));
            }

            foreach (XmlNode child in node.ChildNodes)
            {
                if (XmlNodeType.Element == child.NodeType)
                {
                    this.core.UnexpectedElement(node, child);
                }
            }

            // Reference ConfigureIIs since nothing will happen without it
            this.core.AddValidReference("CustomAction", "ConfigureIIs");

            Row row = this.core.CreateRow(sourceLineNumbers, "IIsWebError");
            row[0] = errorCode;
            row[1] = subCode;
            row[2] = (int)parentType;
            row[3] = parent;
            row[4] = file;
            row[5] = url;
        }