| | | 1 | | using System; |
| | | 2 | | using System.Xml.Linq; |
| | | 3 | | |
| | | 4 | | namespace DirectSight.Common; |
| | | 5 | | |
| | | 6 | | /// <summary> |
| | | 7 | | /// Linq extensions. |
| | | 8 | | /// </summary> |
| | | 9 | | internal static class LinqExtensions |
| | | 10 | | { |
| | | 11 | | /// <summary> |
| | | 12 | | /// Determines whether a <see cref="XElement"/> has an <see cref="XAttribute"/> with the given value.. |
| | | 13 | | /// </summary> |
| | | 14 | | /// <param name="element">The <see cref="XElement"/>.</param> |
| | | 15 | | /// <param name="attributeName">The name of the attribute.</param> |
| | | 16 | | /// <param name="attributeValue">The attribute value.</param> |
| | | 17 | | /// <returns> |
| | | 18 | | /// <c>true</c> if <see cref="XElement"/> has an <see cref="XAttribute"/> with the given value; otherwise, <c>fals |
| | | 19 | | /// </returns> |
| | | 20 | | internal static bool HasAttributeWithValue(this XElement element, XName attributeName, string attributeValue) |
| | 16526 | 21 | | { |
| | 16526 | 22 | | if (element == null) |
| | 0 | 23 | | { |
| | 0 | 24 | | throw new ArgumentNullException(nameof(element)); |
| | | 25 | | } |
| | | 26 | | |
| | 16526 | 27 | | XAttribute attribute = element.Attribute(attributeName); |
| | | 28 | | |
| | 16526 | 29 | | if (attribute == null) |
| | 0 | 30 | | { |
| | 0 | 31 | | return false; |
| | | 32 | | } |
| | | 33 | | else |
| | 16526 | 34 | | { |
| | 16526 | 35 | | return string.Equals(attribute.Value, attributeValue, StringComparison.OrdinalIgnoreCase); |
| | | 36 | | } |
| | 16526 | 37 | | } |
| | | 38 | | } |