XElementExtensions.GetElementValueAsEnum method

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

GetElementValueAsEnum<T>(XElement, string)

Extension method

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

public static T GetElementValueAsEnum<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 element should match.

Returns

T

An instance of T representing the element value.

GetElementValueAsEnum<T>(XElement, string, T)

Extension method

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

public static T GetElementValueAsEnum<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 element should match.

fallback T

An instance of T used as fallback.

Returns

T

An instance of T representing the element value.

GetElementValueAsEnum<T>(XElement, string, IXmlNamespaceResolver)

Extension method

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

public static T GetElementValueAsEnum<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 element should match.

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

Returns

T

An instance of T representing the element value.

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

Extension method

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

public static T GetElementValueAsEnum<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 element 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 element value.

GetElementValueAsEnum<T>(XElement, XName)

Extension method

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

public static T GetElementValueAsEnum<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 element should match.

Returns

T

An instance of T representing the element value.

GetElementValueAsEnum<T>(XElement, XName, T)

Extension method

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

public static T GetElementValueAsEnum<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 element should match.

fallback T

An instance of T used as fallback.

Returns

T

An instance of T representing the element value.