XElementExtensions.GetElementValueAsEnum method
| Namespace | Skybrud.Essentials.Xml.Extensions | 
|---|---|
| Assembly | Skybrud.Essentials.dll | 
GetElementValueAsEnum<T>(XElement, string)
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
expression
                                String 
                            The XPath expression the element should match.
Returns
T
                        An instance of T representing the element value.
GetElementValueAsEnum<T>(XElement, string, T)
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
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)
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
expression
                                String 
                            The XPath expression the element should match.
resolver
                                IXmlNamespaceResolver 
                            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)
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
expression
                                String 
                            The XPath expression the element should match.
resolver
                                IXmlNamespaceResolver 
                            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)
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.
Returns
T
                        An instance of T representing the element value.
GetElementValueAsEnum<T>(XElement, XName, T)
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
fallback
                                T
                            An instance of T used as fallback.
Returns
T
                        An instance of T representing the element value.
