Beispiel #1
0
        internal static string GetAttributeIdentifierValue(SourceLineNumberCollection sourceLineNumbers, XmlAttribute attribute, Action <MessageEventArgs> messageHandler)
        {
            if (null == attribute)
            {
                throw new ArgumentNullException("attribute");
            }

            string value = Common.GetAttributeValue(sourceLineNumbers, attribute, EmptyRule.CanBeWhitespaceOnly, messageHandler);

            if (Common.IsIdentifier(value))
            {
                if (72 < value.Length && null != messageHandler)
                {
                    messageHandler(WixWarnings.IdentifierTooLong(sourceLineNumbers, attribute.OwnerElement.Name, attribute.Name, value));
                }

                return(value);
            }
            else
            {
                if (value.StartsWith("[", StringComparison.Ordinal) && value.EndsWith("]", StringComparison.Ordinal) && null != messageHandler)
                {
                    messageHandler(WixErrors.IllegalIdentifierLooksLikeFormatted(sourceLineNumbers, attribute.OwnerElement.Name, attribute.Name, value));
                }
                else if (null != messageHandler)
                {
                    messageHandler(WixErrors.IllegalIdentifier(sourceLineNumbers, attribute.OwnerElement.Name, attribute.Name, value));
                }

                return(String.Empty);
            }
        }