Пример #1
0
        /// <summary>
        /// Returns the value of the attribute.
        /// If the attribute is not present, returns either null or an empty string, depending on the value
        /// of returnNullForNonexistentAttributes.
        /// </summary>
        internal static string GetAttributeValue(XmlElementWithLocation element, string attributeName, bool returnNullForNonexistentAttributes)
        {
            XmlAttributeWithLocation attribute = (XmlAttributeWithLocation)element.GetAttributeNode(attributeName);

            return(GetAttributeValue(attribute, returnNullForNonexistentAttributes));
        }
Пример #2
0
 /// <summary>
 /// Throw an invalid project exception indicating that the child is not valid beneath the element because it is a duplicate
 /// </summary>
 internal static void ThrowProjectInvalidChildElementDueToDuplicate(XmlElementWithLocation child)
 {
     ProjectErrorUtilities.ThrowInvalidProject(child.Location, "InvalidChildElementDueToDuplication", child.Name, child.ParentNode.Name);
 }
Пример #3
0
 /// <summary>
 /// Gets child elements, ignoring whitespace and comments.
 /// Verifies xml namespace of elements is the MSBuild namespace.
 /// Throws InvalidProjectFileException for elements in the wrong namespace, and unexpected XML node types
 /// </summary>
 internal static List <XmlElementWithLocation> GetVerifyThrowProjectChildElements(XmlElementWithLocation element)
 {
     return(GetChildElements(element, true /*throw for unexpected node types*/));
 }
Пример #4
0
 /// <summary>
 /// Returns the value of the attribute.
 /// If the attribute is not present, returns an empty string.
 /// </summary>
 internal static string GetAttributeValue(XmlElementWithLocation element, string attributeName)
 {
     return(GetAttributeValue(element, attributeName, false /* if the attribute is not present, return an empty string */));
 }
Пример #5
0
 /// <summary>
 /// Sets the value of an attribute, but if the value to set is null or empty, just
 /// removes the attribute. Returns the attribute, or null if it was removed.
 /// UNDONE: Make this return a bool if the attribute did not change, so we can avoid dirtying.
 /// </summary>
 internal static XmlAttributeWithLocation SetOrRemoveAttribute(XmlElementWithLocation element, string name, string value)
 {
     return(SetOrRemoveAttribute(element, name, value, false /* remove the attribute if setting to empty string */));
 }
Пример #6
0
 /// <summary>
 /// Verify that the element has the specified required attribute on it and
 /// it has a value other than empty string
 /// </summary>
 internal static void VerifyThrowProjectRequiredAttribute(XmlElementWithLocation element, string attributeName)
 {
     ProjectErrorUtilities.VerifyThrowInvalidProject(element.GetAttribute(attributeName).Length > 0, element.Location, "MissingRequiredAttribute", attributeName, element.Name);
 }
Пример #7
0
 /// <summary>
 /// Verifies that if the attribute is present on the element, its value is not empty
 /// </summary>
 internal static void VerifyThrowProjectAttributeEitherMissingOrNotEmpty(XmlElementWithLocation xmlElement, string attributeName)
 {
     VerifyThrowProjectAttributeEitherMissingOrNotEmpty(xmlElement, xmlElement.GetAttributeWithLocation(attributeName), attributeName);
 }
Пример #8
0
 /// <summary>
 /// Gets child elements, ignoring whitespace and comments.
 /// Throws InvalidProjectFileException for unexpected XML node types if parameter is set.
 /// </summary>
 private static XmlElementChildIterator GetChildElements(XmlElementWithLocation element, bool throwForInvalidNodeTypes)
 {
     return(new XmlElementChildIterator(element, throwForInvalidNodeTypes));
 }
Пример #9
0
        /// <summary>
        /// Returns the value of the attribute.
        /// If the attribute is not present, returns either null or an empty string, depending on the value
        /// of nullIfNotExists.
        /// </summary>
        internal static string GetAttributeValue(XmlElementWithLocation element, string attributeName, bool nullIfNotExists)
        {
            XmlAttributeWithLocation attribute = (XmlAttributeWithLocation)element.GetAttributeNode(attributeName);

            return(GetAttributeValue(attribute, nullIfNotExists));
        }