XElementExtensions.GetAttributeValueAsEnum method

Version 1.1.28
.NET Framework 4.8
Namespace Skybrud.Essentials.Xml.Extensions
Assembly Skybrud.Essentials.dll

GetAttributeValueAsEnum<T>(XElement, string)

Extension method

Gets an instance of T representing the value of the first attribute matching the specified XPath expression.

public static T GetAttributeValueAsEnum<T>(this XElement element, string expression)

Type Parameters

T

The enum type the value should be converted to.

Parameters

element XElement

The XElement .

expression String

The XPath expression the attribute should match.

Returns

T

An instance of T representing the attribute value.

GetAttributeValueAsEnum<T>(XElement, string, T)

Extension method

Gets an instance of T representing the value of the first attribute matching the specified XPath expression. If the attribute value can't be converted, fallback is returned instead.

public static T GetAttributeValueAsEnum<T>(this XElement element, string expression, T fallback)

Type Parameters

T

The enum type the value should be converted to.

Parameters

element XElement

The XElement .

expression String

The XPath expression the attribute should match.

fallback T

An instance of T used as fallback.

Returns

T

An instance of T representing the attribute value.

GetAttributeValueAsEnum<T>(XElement, string, IXmlNamespaceResolver)

Extension method

Gets an instance of T representing the value of the first attribute matching the specified XPath expression.

public static T GetAttributeValueAsEnum<T>(this XElement element, string expression, IXmlNamespaceResolver resolver)

Type Parameters

T

The enum type the value should be converted to.

Parameters

element XElement

The XElement .

expression String

The XPath expression the attribute should match.

An instance of IXmlNamespaceResolver for resolving namespace prefixes in the XPath expression.

Returns

T

An instance of T representing the attribute value.

GetAttributeValueAsEnum<T>(XElement, string, IXmlNamespaceResolver, T)

Extension method

Gets an instance of T representing the value of the first attribute matching the specified XPath expression. If the attribute value can't be converted, fallback is returned instead.

public static T GetAttributeValueAsEnum<T>(this XElement element, string expression, IXmlNamespaceResolver resolver, T fallback)

Type Parameters

T

The enum type the value should be converted to.

Parameters

element XElement

The XElement .

expression String

The XPath expression the attribute should match.

An instance of IXmlNamespaceResolver for resolving namespace prefixes in the XPath expression.

fallback T

An instance of T used as fallback.

Returns

T

An instance of T representing the attribute value.

GetAttributeValueAsEnum<T>(XElement, XName)

Extension method

Gets an instance of T representing the value of the first attribute matching the specified name.

public static T GetAttributeValueAsEnum<T>(this XElement element, XName name)

Type Parameters

T

The enum type the value should be converted to.

Parameters

element XElement

The XElement .

name XName

The XName the attribute should match.

Returns

T

An instance of T representing the attribute value.

GetAttributeValueAsEnum<T>(XElement, XName, T)

Extension method

Gets an instance of T representing the value of the first attribute matching the specified name. If the attribute value can't be converted, fallback is returned instead.

public static T GetAttributeValueAsEnum<T>(this XElement element, XName name, T fallback)

Type Parameters

T

The enum type the value should be converted to.

Parameters

element XElement

The XElement .

name XName

The XName the attribute should match.

fallback T

An instance of T used as fallback.

Returns

T

An instance of T representing the attribute value.