• Share
    • Twitter
    • LinkedIn
    • Facebook
    • Email
  • Feedback
  • Improve this Doc

Class CollectionExtensions

Provides a collection of useful extensions to collections.

Inheritance
System.Object
CollectionExtensions
Namespace: DotNetNuke.Collections
Assembly: DotNetNuke.dll
Syntax
public static class CollectionExtensions : object

Methods

| Improve this Doc View Source

CreateDictionaryFromString(String, Char, Char)

Converts a string with multiple key-value pairs into a Dictionary, if there are duplicated keys in your string only the first found key is kept since keys must be unique in a Dictionary.

Declaration
public static Dictionary<string, string> CreateDictionaryFromString(string stringOfPairs, char pairsSeparator, char pairSeparator)
Parameters
Type Name Description
System.String stringOfPairs

The string containing the key-value pairs.

System.Char pairsSeparator

The separator used to separate each key-value pair.

System.Char pairSeparator

The separator used between the each key and value.

Returns
Type Description
Dictionary<System.String, System.String>

Dictionary with a string key and a string value.

| Improve this Doc View Source

DictionaryToString(Dictionary<String, String>, String, String)

Converts a Dictionary with a string key and a string value into a plain string separated by your choice of separators.

Declaration
public static string DictionaryToString(this Dictionary<string, string> dictionary, string pairsSeparator, string pairSeparator)
Parameters
Type Name Description
Dictionary<System.String, System.String> dictionary

The Dictionary to convert.

System.String pairsSeparator

The separator to use between key-value pairs.

System.String pairSeparator

The separator to use between each key and value.

Returns
Type Description
System.String

The dictionary's contents as a .

| Improve this Doc View Source

ForEach<TType>(IEnumerable<TType>, Action<TType>)

Executes an action for each element in the source collection.

Declaration
public static IEnumerable<TType> ForEach<TType>(this IEnumerable<TType> source, Action<TType> action)
Parameters
Type Name Description
IEnumerable<TType> source

The source.

Action<TType> action

The action.

Returns
Type Description
IEnumerable<TType>

The provided source after the action was performed on each element.

Type Parameters
Name Description
TType

The type of the type.

| Improve this Doc View Source

GetFlexibleBooleanParsingFunction()

Gets a converter function which parses a value into a . Considers the value true if it is one of the following (case-insensitive):

  • true
  • on
  • 1
  • yes
Declaration
public static Func<string, bool> GetFlexibleBooleanParsingFunction()
Returns
Type Description
Func<System.String, System.Boolean>

A instance.

| Improve this Doc View Source

GetFlexibleBooleanParsingFunction(String[])

Gets a converter function which parses a value into a .

Declaration
public static Func<string, bool> GetFlexibleBooleanParsingFunction(params string[] trueValues)
Parameters
Type Name Description
System.String[] trueValues

The values (case-insensitive) which should be parsed as true.

Returns
Type Description
Func<System.String, System.Boolean>

A instance.

| Improve this Doc View Source

GetValue<T>(IDictionary, String, Func<Object, T>)

Gets the value from the dictionary.

Declaration
public static T GetValue<T>(this IDictionary dictionary, string key, Func<object, T> converter)
Parameters
Type Name Description
IDictionary dictionary

The dictionary.

System.String key

The key by which to get the value.

Func<System.Object, T> converter

A function to convert the value as an to a T instance.

Returns
Type Description
T

A T instance.

Type Parameters
Name Description
T

The type of the value to retrieve.

| Improve this Doc View Source

GetValue<T>(IDictionary, String, Func<String, T>)

Gets the value from the dictionary.

Declaration
public static T GetValue<T>(this IDictionary dictionary, string key, Func<string, T> converter)
Parameters
Type Name Description
IDictionary dictionary

The dictionary.

System.String key

The key by which to get the value.

Func<System.String, T> converter

A function to convert the value as an to a T instance.

Returns
Type Description
T

A T instance.

Type Parameters
Name Description
T

The type of the value to retrieve.

| Improve this Doc View Source

GetValue<T>(IDictionary, String)

Gets the value from the dictionary.

Declaration
public static T GetValue<T>(this IDictionary dictionary, string key)
Parameters
Type Name Description
IDictionary dictionary

The dictionary.

System.String key

The key by which to get the value.

Returns
Type Description
T

A T instance.

Type Parameters
Name Description
T

The type of the value to retrieve.

| Improve this Doc View Source

GetValue<T>(ILookup<String, String>, String, Func<Object, T>)

Gets the value from the lookup.

Declaration
public static T GetValue<T>(this ILookup<string, string> lookup, string key, Func<object, T> converter)
Parameters
Type Name Description
ILookup<System.String, System.String> lookup

The lookup.

System.String key

The key by which to get the value.

Func<System.Object, T> converter

A function to convert the value as an to a T instance.

Returns
Type Description
T

A T instance.

Type Parameters
Name Description
T

The type of the value to retrieve.

| Improve this Doc View Source

GetValue<T>(ILookup<String, String>, String, Func<String, T>)

Gets the value from the lookup.

Declaration
public static T GetValue<T>(this ILookup<string, string> lookup, string key, Func<string, T> converter)
Parameters
Type Name Description
ILookup<System.String, System.String> lookup

The lookup.

System.String key

The key by which to get the value.

Func<System.String, T> converter

A function to convert the value as an to a T instance.

Returns
Type Description
T

A T instance.

Type Parameters
Name Description
T

The type of the value to retrieve.

| Improve this Doc View Source

GetValue<T>(ILookup<String, String>, String)

Gets the value from the lookup.

Declaration
public static T GetValue<T>(this ILookup<string, string> lookup, string key)
Parameters
Type Name Description
ILookup<System.String, System.String> lookup

The lookup.

System.String key

The key by which to get the value.

Returns
Type Description
T

A T instance.

Type Parameters
Name Description
T

The type of the value to retrieve.

| Improve this Doc View Source

GetValue<T>(IXPathNavigable, String, Func<Object, T>)

Gets the value from the XML node's child elements.

Declaration
public static T GetValue<T>(this IXPathNavigable node, string key, Func<object, T> converter)
Parameters
Type Name Description
IXPathNavigable node

An XML node which containers other elements.

System.String key

The name of the element from which to get the value.

Func<System.Object, T> converter

A function to convert the value as an to a T instance.

Returns
Type Description
T

A T instance.

Type Parameters
Name Description
T

The type of the value to retrieve.

| Improve this Doc View Source

GetValue<T>(IXPathNavigable, String, Func<String, T>)

Gets the value from the XML node's child elements.

Declaration
public static T GetValue<T>(this IXPathNavigable node, string key, Func<string, T> converter)
Parameters
Type Name Description
IXPathNavigable node

An XML node which containers other elements.

System.String key

The name of the element from which to get the value.

Func<System.String, T> converter

A function to convert the value as an to a T instance.

Returns
Type Description
T

A T instance.

Type Parameters
Name Description
T

The type of the value to retrieve.

| Improve this Doc View Source

GetValue<T>(IXPathNavigable, String)

Gets the value from the XML node's child elements, returning the default value of if the value doesn't exist.

Declaration
public static T GetValue<T>(this IXPathNavigable node, string key)
Parameters
Type Name Description
IXPathNavigable node

An XML node which containers other elements.

System.String key

The name of the element from which to get the value.

Returns
Type Description
T

A T instance.

Type Parameters
Name Description
T

The type of the value to retrieve.

| Improve this Doc View Source

GetValue<T>(NameValueCollection, String, Func<Object, T>)

Gets the value from the collection.

Declaration
public static T GetValue<T>(this NameValueCollection collection, string key, Func<object, T> converter)
Parameters
Type Name Description
NameValueCollection collection

The collection.

System.String key

The key by which to get the value.

Func<System.Object, T> converter

A function to convert the value as an to a T instance.

Returns
Type Description
T

A T instance.

Type Parameters
Name Description
T

The type of the value to retrieve.

| Improve this Doc View Source

GetValue<T>(NameValueCollection, String, Func<String, T>)

Gets the value from the collection.

Declaration
public static T GetValue<T>(this NameValueCollection collection, string key, Func<string, T> converter)
Parameters
Type Name Description
NameValueCollection collection

The collection.

System.String key

The key by which to get the value.

Func<System.String, T> converter

A function to convert the value as an to a T instance.

Returns
Type Description
T

A T instance.

Type Parameters
Name Description
T

The type of the value to retrieve.

| Improve this Doc View Source

GetValue<T>(NameValueCollection, String)

Gets the value from the collection.

Declaration
public static T GetValue<T>(this NameValueCollection collection, string key)
Parameters
Type Name Description
NameValueCollection collection

The collection.

System.String key

The key by which to get the value.

Returns
Type Description
T

A T instance.

Type Parameters
Name Description
T

The type of the value to retrieve.

| Improve this Doc View Source

GetValue<T>(XContainer, String, Func<Object, T>)

Gets the value from the XML node's child elements.

Declaration
public static T GetValue<T>(this XContainer node, string key, Func<object, T> converter)
Parameters
Type Name Description
XContainer node

An XML node which containers other elements.

System.String key

The name of the element from which to get the value.

Func<System.Object, T> converter

A function to convert the value as an to a T instance.

Returns
Type Description
T

A T instance.

Type Parameters
Name Description
T

The type of the value to retrieve.

| Improve this Doc View Source

GetValue<T>(XContainer, String, Func<String, T>)

Gets the value from the XML node's child elements.

Declaration
public static T GetValue<T>(this XContainer node, string key, Func<string, T> converter)
Parameters
Type Name Description
XContainer node

An XML node which containers other elements.

System.String key

The name of the element from which to get the value.

Func<System.String, T> converter

A function to convert the value as an to a T instance.

Returns
Type Description
T

A T instance.

Type Parameters
Name Description
T

The type of the value to retrieve.

| Improve this Doc View Source

GetValue<T>(XContainer, String)

Gets the value from the XML node's child elements.

Declaration
public static T GetValue<T>(this XContainer node, string key)
Parameters
Type Name Description
XContainer node

An XML node which containers other elements.

System.String key

The name of the element from which to get the value.

Returns
Type Description
T

A T instance.

Type Parameters
Name Description
T

The type of the value to retrieve.

| Improve this Doc View Source

GetValueOrDefault<T>(IDictionary, String, T, Func<Object, T>)

Gets the value from the dictionary, returning the if the value doesn't exist.

Declaration
public static T GetValueOrDefault<T>(this IDictionary dictionary, string key, T defaultValue, Func<object, T> converter)
Parameters
Type Name Description
IDictionary dictionary

The dictionary.

System.String key

The key by which to get the value.

T defaultValue

The default value to return if the dictionary doesn't have a value for the given key.

Func<System.Object, T> converter

A function to convert the value as an to a T instance.

Returns
Type Description
T

A T instance.

Type Parameters
Name Description
T

The type of the value to retrieve.

| Improve this Doc View Source

GetValueOrDefault<T>(IDictionary, String, T, Func<String, T>)

Gets the value from the dictionary, returning defaultValue if the value doesn't exist.

Declaration
public static T GetValueOrDefault<T>(this IDictionary dictionary, string key, T defaultValue, Func<string, T> converter)
Parameters
Type Name Description
IDictionary dictionary

The dictionary.

System.String key

The key by which to get the value.

T defaultValue

The default value to return if the dictionary doesn't have a value for the given key.

Func<System.String, T> converter

A function to convert the value as an to a T instance.

Returns
Type Description
T

A T instance.

Type Parameters
Name Description
T

The type of the value to retrieve.

| Improve this Doc View Source

GetValueOrDefault<T>(IDictionary, String, T)

Gets the value from the dictionary, returning defaultValue if the value doesn't exist.

Declaration
public static T GetValueOrDefault<T>(this IDictionary dictionary, string key, T defaultValue)
Parameters
Type Name Description
IDictionary dictionary

The dictionary.

System.String key

The key by which to get the value.

T defaultValue

The default value to return if the dictionary doesn't have a value for the given key.

Returns
Type Description
T

A T instance.

Type Parameters
Name Description
T

The type of the value to retrieve.

| Improve this Doc View Source

GetValueOrDefault<T>(IDictionary, String, Func<Object, T>)

Gets the value from the dictionary, returning the default value of if the value doesn't exist.

Declaration
public static T GetValueOrDefault<T>(this IDictionary dictionary, string key, Func<object, T> converter)
Parameters
Type Name Description
IDictionary dictionary

The dictionary.

System.String key

The key by which to get the value.

Func<System.Object, T> converter

A function to convert the value as an to a T instance.

Returns
Type Description
T

A T instance.

Type Parameters
Name Description
T

The type of the value to retrieve.

| Improve this Doc View Source

GetValueOrDefault<T>(IDictionary, String, Func<String, T>)

Gets the value from the dictionary, returning the default value of if the value doesn't exist.

Declaration
public static T GetValueOrDefault<T>(this IDictionary dictionary, string key, Func<string, T> converter)
Parameters
Type Name Description
IDictionary dictionary

The dictionary.

System.String key

The key by which to get the value.

Func<System.String, T> converter

A function to convert the value as an to a T instance.

Returns
Type Description
T

A T instance.

Type Parameters
Name Description
T

The type of the value to retrieve.

| Improve this Doc View Source

GetValueOrDefault<T>(IDictionary, String)

Gets the value from the dictionary, returning the default value of if the value doesn't exist.

Declaration
public static T GetValueOrDefault<T>(this IDictionary dictionary, string key)
Parameters
Type Name Description
IDictionary dictionary

The dictionary.

System.String key

The key by which to get the value.

Returns
Type Description
T

A T instance.

Type Parameters
Name Description
T

The type of the value to retrieve.

| Improve this Doc View Source

GetValueOrDefault<T>(ILookup<String, String>, String, T, Func<Object, T>)

Gets the value from the lookup, returning defaultValue if the value doesn't exist.

Declaration
public static T GetValueOrDefault<T>(this ILookup<string, string> lookup, string key, T defaultValue, Func<object, T> converter)
Parameters
Type Name Description
ILookup<System.String, System.String> lookup

The lookup.

System.String key

The key by which to get the value.

T defaultValue

The default value to return if the lookup doesn't have a value for the given key.

Func<System.Object, T> converter

A function to convert the value as an to a T instance.

Returns
Type Description
T

A T instance.

Type Parameters
Name Description
T

The type of the value to retrieve.

| Improve this Doc View Source

GetValueOrDefault<T>(ILookup<String, String>, String, T, Func<String, T>)

Gets the value from the lookup, returning defaultValue if the value doesn't exist.

Declaration
public static T GetValueOrDefault<T>(this ILookup<string, string> lookup, string key, T defaultValue, Func<string, T> converter)
Parameters
Type Name Description
ILookup<System.String, System.String> lookup

The lookup.

System.String key

The key by which to get the value.

T defaultValue

The default value to return if the lookup doesn't have a value for the given key.

Func<System.String, T> converter

A function to convert the value as an to a T instance.

Returns
Type Description
T

A T instance.

Type Parameters
Name Description
T

The type of the value to retrieve.

| Improve this Doc View Source

GetValueOrDefault<T>(ILookup<String, String>, String, T)

Gets the value from the lookup, returning defaultValue if the value doesn't exist.

Declaration
public static T GetValueOrDefault<T>(this ILookup<string, string> lookup, string key, T defaultValue)
Parameters
Type Name Description
ILookup<System.String, System.String> lookup

The lookup.

System.String key

The key by which to get the value.

T defaultValue

The default value to return if the lookup doesn't have a value for the given key.

Returns
Type Description
T

A T instance.

Type Parameters
Name Description
T

The type of the value to retrieve.

| Improve this Doc View Source

GetValueOrDefault<T>(ILookup<String, String>, String, Func<Object, T>)

Gets the value from the lookup, returning the default value of if the value doesn't exist.

Declaration
public static T GetValueOrDefault<T>(this ILookup<string, string> lookup, string key, Func<object, T> converter)
Parameters
Type Name Description
ILookup<System.String, System.String> lookup

The lookup.

System.String key

The key by which to get the value.

Func<System.Object, T> converter

A function to convert the value as an to a T instance.

Returns
Type Description
T

A T instance.

Type Parameters
Name Description
T

The type of the value to retrieve.

| Improve this Doc View Source

GetValueOrDefault<T>(ILookup<String, String>, String, Func<String, T>)

Gets the value from the lookup, returning the default value of if the value doesn't exist.

Declaration
public static T GetValueOrDefault<T>(this ILookup<string, string> lookup, string key, Func<string, T> converter)
Parameters
Type Name Description
ILookup<System.String, System.String> lookup

The lookup.

System.String key

The key by which to get the value.

Func<System.String, T> converter

A function to convert the value as an to a T instance.

Returns
Type Description
T

A T instance.

Type Parameters
Name Description
T

The type of the value to retrieve.

| Improve this Doc View Source

GetValueOrDefault<T>(ILookup<String, String>, String)

Gets the value from the lookup, returning the default value of if the value doesn't exist.

Declaration
public static T GetValueOrDefault<T>(this ILookup<string, string> lookup, string key)
Parameters
Type Name Description
ILookup<System.String, System.String> lookup

The lookup.

System.String key

The key by which to get the value.

Returns
Type Description
T

A T instance.

Type Parameters
Name Description
T

The type of the value to retrieve.

| Improve this Doc View Source

GetValueOrDefault<T>(IXPathNavigable, String, T, Func<Object, T>)

Gets the value from the XML node's child elements, returning defaultValue if the value doesn't exist.

Declaration
public static T GetValueOrDefault<T>(this IXPathNavigable node, string key, T defaultValue, Func<object, T> converter)
Parameters
Type Name Description
IXPathNavigable node

An XML node which containers other elements.

System.String key

The name of the element from which to get the value.

T defaultValue

The default value to return if the node doesn't have a value for the given key.

Func<System.Object, T> converter

A function to convert the value as an to a T instance.

Returns
Type Description
T

A T instance.

Type Parameters
Name Description
T

The type of the value to retrieve.

| Improve this Doc View Source

GetValueOrDefault<T>(IXPathNavigable, String, T, Func<String, T>)

Gets the value from the XML node's child elements, returning defaultValue if the value doesn't exist.

Declaration
public static T GetValueOrDefault<T>(this IXPathNavigable node, string key, T defaultValue, Func<string, T> converter)
Parameters
Type Name Description
IXPathNavigable node

An XML node which containers other elements.

System.String key

The name of the element from which to get the value.

T defaultValue

The default value to return if the node doesn't have a value for the given key.

Func<System.String, T> converter

A function to convert the value as a to a T instance.

Returns
Type Description
T

A T instance.

Type Parameters
Name Description
T

The type of the value to retrieve.

| Improve this Doc View Source

GetValueOrDefault<T>(IXPathNavigable, String, T)

Gets the value from the XML node's child elements, returning defaultValue if the value doesn't exist.

Declaration
public static T GetValueOrDefault<T>(this IXPathNavigable node, string key, T defaultValue)
Parameters
Type Name Description
IXPathNavigable node

An XML node which containers other elements.

System.String key

The name of the element from which to get the value.

T defaultValue

The default value to return if the node doesn't have a value for the given key.

Returns
Type Description
T

A T instance.

Type Parameters
Name Description
T

The type of the value to retrieve.

| Improve this Doc View Source

GetValueOrDefault<T>(IXPathNavigable, String, Func<Object, T>)

Gets the value from the XML node's child elements, returning the default value of if the value doesn't exist.

Declaration
public static T GetValueOrDefault<T>(this IXPathNavigable node, string key, Func<object, T> converter)
Parameters
Type Name Description
IXPathNavigable node

An XML node which containers other elements.

System.String key

The name of the element from which to get the value.

Func<System.Object, T> converter

A function to convert the value as an to a T instance.

Returns
Type Description
T

A T instance.

Type Parameters
Name Description
T

The type of the value to retrieve.

| Improve this Doc View Source

GetValueOrDefault<T>(IXPathNavigable, String, Func<String, T>)

Gets the value from the XML node's child elements, returning the default value of if the value doesn't exist.

Declaration
public static T GetValueOrDefault<T>(this IXPathNavigable node, string key, Func<string, T> converter)
Parameters
Type Name Description
IXPathNavigable node

An XML node which containers other elements.

System.String key

The name of the element from which to get the value.

Func<System.String, T> converter

A function to convert the value as an to a T instance.

Returns
Type Description
T

A T instance.

Type Parameters
Name Description
T

The type of the value to retrieve.

| Improve this Doc View Source

GetValueOrDefault<T>(IXPathNavigable, String)

Gets the value from the XML node's child elements, returning the default value of if the value doesn't exist.

Declaration
public static T GetValueOrDefault<T>(this IXPathNavigable node, string key)
Parameters
Type Name Description
IXPathNavigable node

An XML node which containers other elements.

System.String key

The name of the element from which to get the value.

Returns
Type Description
T

A T instance.

Type Parameters
Name Description
T

The type of the value to retrieve.

| Improve this Doc View Source

GetValueOrDefault<T>(NameValueCollection, String, T, Func<Object, T>)

Gets the value from the collection, returning defaultValue if the value doesn't exist.

Declaration
public static T GetValueOrDefault<T>(this NameValueCollection collection, string key, T defaultValue, Func<object, T> converter)
Parameters
Type Name Description
NameValueCollection collection

The collection.

System.String key

The key by which to get the value.

T defaultValue

The default value to return if the collection doesn't have a value for the given key.

Func<System.Object, T> converter

A function to convert the value as an to a T instance.

Returns
Type Description
T

A T instance.

Type Parameters
Name Description
T

The type of the value to retrieve.

| Improve this Doc View Source

GetValueOrDefault<T>(NameValueCollection, String, T, Func<String, T>)

Gets the value from the collection, returning defaultValue if the value doesn't exist.

Declaration
public static T GetValueOrDefault<T>(this NameValueCollection collection, string key, T defaultValue, Func<string, T> converter)
Parameters
Type Name Description
NameValueCollection collection

The collection.

System.String key

The key by which to get the value.

T defaultValue

The default value to return if the collection doesn't have a value for the given key.

Func<System.String, T> converter

A function to convert the value as an to a T instance.

Returns
Type Description
T

A T instance.

Type Parameters
Name Description
T

The type of the value to retrieve.

| Improve this Doc View Source

GetValueOrDefault<T>(NameValueCollection, String, T)

Gets the value from the collection, returning defaultValue if the value doesn't exist.

Declaration
public static T GetValueOrDefault<T>(this NameValueCollection collection, string key, T defaultValue)
Parameters
Type Name Description
NameValueCollection collection

The collection.

System.String key

The key by which to get the value.

T defaultValue

The default value to return if the collection doesn't have a value for the given key.

Returns
Type Description
T

A T instance.

Type Parameters
Name Description
T

The type of the value to retrieve.

| Improve this Doc View Source

GetValueOrDefault<T>(NameValueCollection, String, Func<Object, T>)

Gets the value from the collection, returning the default value of if the value doesn't exist.

Declaration
public static T GetValueOrDefault<T>(this NameValueCollection collection, string key, Func<object, T> converter)
Parameters
Type Name Description
NameValueCollection collection

The collection.

System.String key

The key by which to get the value.

Func<System.Object, T> converter

A function to convert the value as an to a T instance.

Returns
Type Description
T

A T instance.

Type Parameters
Name Description
T

The type of the value to retrieve.

| Improve this Doc View Source

GetValueOrDefault<T>(NameValueCollection, String, Func<String, T>)

Gets the value from the collection, returning the default value of if the value doesn't exist.

Declaration
public static T GetValueOrDefault<T>(this NameValueCollection collection, string key, Func<string, T> converter)
Parameters
Type Name Description
NameValueCollection collection

The collection.

System.String key

The key by which to get the value.

Func<System.String, T> converter

A function to convert the value as an to a T instance.

Returns
Type Description
T

A T instance.

Type Parameters
Name Description
T

The type of the value to retrieve.

| Improve this Doc View Source

GetValueOrDefault<T>(NameValueCollection, String)

Gets the value from the collection, returning the default value of if the value doesn't exist.

Declaration
public static T GetValueOrDefault<T>(this NameValueCollection collection, string key)
Parameters
Type Name Description
NameValueCollection collection

The collection.

System.String key

The key by which to get the value.

Returns
Type Description
T

A T instance.

Type Parameters
Name Description
T

The type of the value to retrieve.

| Improve this Doc View Source

GetValueOrDefault<T>(XContainer, String, T, Func<Object, T>)

Gets the value from the XML node's child elements, returning defaultValue if the value doesn't exist.

Declaration
public static T GetValueOrDefault<T>(this XContainer node, string key, T defaultValue, Func<object, T> converter)
Parameters
Type Name Description
XContainer node

An XML node which containers other elements.

System.String key

The name of the element from which to get the value.

T defaultValue

The default value to return if the node doesn't have a value for the given key.

Func<System.Object, T> converter

A function to convert the value as an to a T instance.

Returns
Type Description
T

A T instance.

Type Parameters
Name Description
T

The type of the value to retrieve.

| Improve this Doc View Source

GetValueOrDefault<T>(XContainer, String, T, Func<String, T>)

Gets the value from the XML node's child elements, returning defaultValue if the value doesn't exist.

Declaration
public static T GetValueOrDefault<T>(this XContainer node, string key, T defaultValue, Func<string, T> converter)
Parameters
Type Name Description
XContainer node

An XML node which containers other elements.

System.String key

The name of the element from which to get the value.

T defaultValue

The default value to return if the node doesn't have a value for the given key.

Func<System.String, T> converter

A function to convert the value as a to a T instance.

Returns
Type Description
T

A T instance.

Type Parameters
Name Description
T

The type of the value to retrieve.

| Improve this Doc View Source

GetValueOrDefault<T>(XContainer, String, T)

Gets the value from the XML node's child elements, returning defaultValue if the value doesn't exist.

Declaration
public static T GetValueOrDefault<T>(this XContainer node, string key, T defaultValue)
Parameters
Type Name Description
XContainer node

An XML node which containers other elements.

System.String key

The name of the element from which to get the value.

T defaultValue

The default value to return if the node doesn't have a value for the given key.

Returns
Type Description
T

A T instance.

Type Parameters
Name Description
T

The type of the value to retrieve.

| Improve this Doc View Source

GetValueOrDefault<T>(XContainer, String, Func<Object, T>)

Gets the value from the XML node's child elements, returning the default value of if the value doesn't exist.

Declaration
public static T GetValueOrDefault<T>(this XContainer node, string key, Func<object, T> converter)
Parameters
Type Name Description
XContainer node

An XML node which containers other elements.

System.String key

The name of the element from which to get the value.

Func<System.Object, T> converter

A function to convert the value as an to a T instance.

Returns
Type Description
T

A T instance.

Type Parameters
Name Description
T

The type of the value to retrieve.

| Improve this Doc View Source

GetValueOrDefault<T>(XContainer, String, Func<String, T>)

Gets the value from the XML node's child elements, returning the default value of if the value doesn't exist.

Declaration
public static T GetValueOrDefault<T>(this XContainer node, string key, Func<string, T> converter)
Parameters
Type Name Description
XContainer node

An XML node which containers other elements.

System.String key

The name of the element from which to get the value.

Func<System.String, T> converter

A function to convert the value as an to a T instance.

Returns
Type Description
T

A T instance.

Type Parameters
Name Description
T

The type of the value to retrieve.

| Improve this Doc View Source

GetValueOrDefault<T>(XContainer, String)

Gets the value from the XML node's child elements, returning the default value of if the value doesn't exist.

Declaration
public static T GetValueOrDefault<T>(this XContainer node, string key)
Parameters
Type Name Description
XContainer node

An XML node which containers other elements.

System.String key

The name of the element from which to get the value.

Returns
Type Description
T

A T instance.

Type Parameters
Name Description
T

The type of the value to retrieve.

| Improve this Doc View Source

GetValues<T>(ILookup<String, String>, String, Func<String, T>)

Gets the values from the lookup.

Declaration
public static IEnumerable<T> GetValues<T>(this ILookup<string, string> lookup, string key, Func<string, T> converter)
Parameters
Type Name Description
ILookup<System.String, System.String> lookup

The lookup.

System.String key

The key by which to get the values.

Func<System.String, T> converter

A function to convert a value as an to a T instance.

Returns
Type Description
IEnumerable<T>

A sequence of T instances.

Type Parameters
Name Description
T

The type of the values to retrieve.

| Improve this Doc View Source

GetValues<T>(ILookup<String, String>, String)

Gets the values from the lookup.

Declaration
public static IEnumerable<T> GetValues<T>(this ILookup<string, string> lookup, string key)
Parameters
Type Name Description
ILookup<System.String, System.String> lookup

The lookup.

System.String key

The key by which to get the values.

Returns
Type Description
IEnumerable<T>

A sequence of T instances.

Type Parameters
Name Description
T

The type of the values to retrieve.

| Improve this Doc View Source

GetValues<T>(NameValueCollection, String, Func<String, T>)

Gets the values from the collection.

Declaration
public static IEnumerable<T> GetValues<T>(this NameValueCollection collection, string key, Func<string, T> converter)
Parameters
Type Name Description
NameValueCollection collection

The collection.

System.String key

The key by which to get the values.

Func<System.String, T> converter

A function to convert a value as an to a T instance.

Returns
Type Description
IEnumerable<T>

A sequence of T instances.

Type Parameters
Name Description
T

The type of the values to retrieve.

| Improve this Doc View Source

GetValues<T>(NameValueCollection, String)

Gets the values from the collection.

Declaration
public static IEnumerable<T> GetValues<T>(this NameValueCollection collection, string key)
Parameters
Type Name Description
NameValueCollection collection

The collection.

System.String key

The key by which to get the values.

Returns
Type Description
IEnumerable<T>

A sequence of T instances.

Type Parameters
Name Description
T

The type of the values to retrieve.

| Improve this Doc View Source

ToLookup(NameValueCollection, Boolean)

Converts the collection to an .

Declaration
public static ILookup<string, string> ToLookup(this NameValueCollection collection, bool splitValues)
Parameters
Type Name Description
NameValueCollection collection

The collection.

System.Boolean splitValues

If true, treats values in the collection as comma-delimited lists of items (e.g. from a ).

Returns
Type Description
ILookup<System.String, System.String>

An instance.

| Improve this Doc View Source

ToLookup(NameValueCollection)

Converts the collection to an .

Declaration
public static ILookup<string, string> ToLookup(this NameValueCollection collection)
Parameters
Type Name Description
NameValueCollection collection

The collection.

Returns
Type Description
ILookup<System.String, System.String>

An instance.

  • View Source
Back to top by the community, for the community... #DNNCMS