PeanutButter
Loading...
Searching...
No Matches
PeanutButter.DuckTyping.Extensions.DuckTypingDictionaryExtensions Class Reference

Provides duck-typing extension methods around dictionary objects. More...

Static Public Member Functions

static T ForceFuzzyDuckAs< T > (this IDictionary< string, object > src)
 Forces approximate ducking around a dictionary. Will "create" underlying "properties" as required. Will attempt to convert to and from the underlying types as required. Will match properties case-insensitive.
static T ForceFuzzyDuckAs< T > (this IDictionary< string, object > src, bool forceConcreteType)
 Forces approximate ducking around a dictionary. Will "create" underlying "properties" as required. Will attempt to convert to and from the underlying types as required. Will match properties case-insensitive.
static T ForceFuzzyDuckAs< T > (this object src)
 Forces approximate ducking around a dictionary. Will "create" underlying "properties" as required. Will attempt to convert to and from the underlying types as required. Will match properties case-insensitive.
static T ForceDuckAs< T > (this IDictionary< string, object > src)
 Forces ducking around a dictionary. This will expect matching of property names (case-sensitive) and types when they are "implemented". Otherwise they will be created as required.
static T DuckAs< T > (this IDictionary< string, object > src, TransformFunc toNativeTransform, TransformFunc fromNativeTransform)
 Performs ducking with property name redirection.
static T DuckAs< T > (this IDictionary< string, object > src, TransformFunc toNativeTransform, TransformFunc fromNativeTransform, bool throwOnError)
 Performs ducking with property name redirection.
static T FuzzyDuckAs< T > (this IDictionary< string, object > src, TransformFunc toNativeTransform, TransformFunc fromNativeTransform)
 Performs fuzzy ducking with property name redirection.
static T FuzzyDuckAs< T > (this IDictionary< string, object > src, TransformFunc toNativeTransform, TransformFunc fromNativeTransform, bool throwOnError)
 Performs fuzzy ducking with property name redirection.
static T FuzzyDuckAs< T > (this IDictionary< string, object > src, string keyPrefix)
 Fuzzy-Ducks a Dictionary (or part thereof) using a key prefix to allow "namespacing" of config.
static T FuzzyDuckAs< T > (this IDictionary< string, object > src, string keyPrefix, bool throwOnError)
 Fuzzy-Ducks a Dictionary (or part thereof) using a key prefix to allow "namespacing" of config.
static T DuckAs< T > (this IDictionary< string, object > src, string keyPrefix)
 Ducks a Dictionary (or part thereof) using a key prefix to allow "namespacing" of config.
static T DuckAs< T > (this IDictionary< string, object > src, string keyPrefix, bool throwOnError)
 Ducks a Dictionary (or part thereof) using a key prefix to allow "namespacing" of config.
static T FuzzyDuckAs< T > (this NameValueCollection src, string keyPrefix)
 Fuzzy-Ducks a NameValueCollection (or part thereof) using a key prefix to allow "namespacing" of config.
static T FuzzyDuckAs< T > (this NameValueCollection src, string keyPrefix, bool throwOnError)
 Fuzzy-Ducks a NameValueCollection (or part thereof) using a key prefix to allow "namespacing" of config.
static T DuckAs< T > (this NameValueCollection src, string keyPrefix)
 Ducks a NameValueCollection (or part thereof) using a key prefix to allow "namespacing" of config.
static T DuckAs< T > (this NameValueCollection src, string keyPrefix, bool throwOnError)
 Ducks a NameValueCollection (or part thereof) using a key prefix to allow "namespacing" of config.

Detailed Description

Provides duck-typing extension methods around dictionary objects.

Member Function Documentation

◆ DuckAs< T >() [1/6]

T PeanutButter.DuckTyping.Extensions.DuckTypingDictionaryExtensions.DuckAs< T > ( this IDictionary< string, object > src,
string keyPrefix )
static

Ducks a Dictionary (or part thereof) using a key prefix to allow "namespacing" of config.

Parameters
srcIDictionary to operate on
keyPrefixkey prefix to take into account
Template Parameters
TInterface to duck onto
Returns
new instance of T, wrapping the Dictionary, or null if unduckable
Type Constraints
T :class 

◆ DuckAs< T >() [2/6]

T PeanutButter.DuckTyping.Extensions.DuckTypingDictionaryExtensions.DuckAs< T > ( this IDictionary< string, object > src,
string keyPrefix,
bool throwOnError )
static

Ducks a Dictionary (or part thereof) using a key prefix to allow "namespacing" of config.

Parameters
srcIDictionary to operate on
keyPrefixkey prefix to take into account
throwOnErrorflag: when unduckable, throw instead of just returning null
Template Parameters
TInterface to duck onto
Returns
new instance of T, wrapping the Dictionary, or null if unduckable
Type Constraints
T :class 

◆ DuckAs< T >() [3/6]

T PeanutButter.DuckTyping.Extensions.DuckTypingDictionaryExtensions.DuckAs< T > ( this IDictionary< string, object > src,
TransformFunc toNativeTransform,
TransformFunc fromNativeTransform )
static

Performs ducking with property name redirection.

Parameters
srcDictionary to duck
toNativeTransformFunc to transform from keys corresponding to T's interface properties to keys that are found in src
fromNativeTransformReverse of toNativeTransform
Template Parameters
TInterface to duck this dictionary as
Returns
New instance of an object implementing T, passing through to the dictionary, or null if unable to duck
Type Constraints
T :class 

◆ DuckAs< T >() [4/6]

T PeanutButter.DuckTyping.Extensions.DuckTypingDictionaryExtensions.DuckAs< T > ( this IDictionary< string, object > src,
TransformFunc toNativeTransform,
TransformFunc fromNativeTransform,
bool throwOnError )
static

Performs ducking with property name redirection.

Parameters
srcDictionary to duck
toNativeTransformFunc to transform from keys corresponding to T's interface properties to keys that are found in src
fromNativeTransformReverse of toNativeTransform
throwOnErrorFlag to throw exception on error instead of just silent failure
Template Parameters
TInterface to duck this dictionary as
Returns
New instance of an object implementing T, passing through to the dictionary, or null if unable to duck
Type Constraints
T :class 

◆ DuckAs< T >() [5/6]

T PeanutButter.DuckTyping.Extensions.DuckTypingDictionaryExtensions.DuckAs< T > ( this NameValueCollection src,
string keyPrefix )
static

Ducks a NameValueCollection (or part thereof) using a key prefix to allow "namespacing" of config.

Parameters
srcNameValueCollection to operate on
keyPrefixkey prefix to take into account
Template Parameters
TInterface to duck onto
Returns
new instance of T, wrapping the NameValueCollection, or null if unduckable
Type Constraints
T :class 

◆ DuckAs< T >() [6/6]

T PeanutButter.DuckTyping.Extensions.DuckTypingDictionaryExtensions.DuckAs< T > ( this NameValueCollection src,
string keyPrefix,
bool throwOnError )
static

Ducks a NameValueCollection (or part thereof) using a key prefix to allow "namespacing" of config.

Parameters
srcNameValueCollection to operate on
keyPrefixkey prefix to take into account
throwOnErrorflag: when unduckable, throw instead of just returning null
Template Parameters
TInterface to duck onto
Returns
new instance of T, wrapping the NameValueCollection, or null if unduckable
Type Constraints
T :class 

◆ ForceDuckAs< T >()

T PeanutButter.DuckTyping.Extensions.DuckTypingDictionaryExtensions.ForceDuckAs< T > ( this IDictionary< string, object > src)
static

Forces ducking around a dictionary. This will expect matching of property names (case-sensitive) and types when they are "implemented". Otherwise they will be created as required.

Parameters
src
Template Parameters
T
Returns

◆ ForceFuzzyDuckAs< T >() [1/3]

T PeanutButter.DuckTyping.Extensions.DuckTypingDictionaryExtensions.ForceFuzzyDuckAs< T > ( this IDictionary< string, object > src)
static

Forces approximate ducking around a dictionary. Will "create" underlying "properties" as required. Will attempt to convert to and from the underlying types as required. Will match properties case-insensitive.

Parameters
src
Template Parameters
T
Returns

◆ ForceFuzzyDuckAs< T >() [2/3]

T PeanutButter.DuckTyping.Extensions.DuckTypingDictionaryExtensions.ForceFuzzyDuckAs< T > ( this IDictionary< string, object > src,
bool forceConcreteType )
static

Forces approximate ducking around a dictionary. Will "create" underlying "properties" as required. Will attempt to convert to and from the underlying types as required. Will match properties case-insensitive.

Parameters
src
forceConcreteTypeforce ducking when T is concrete without virtual/abstract members
Template Parameters
T
Returns

◆ ForceFuzzyDuckAs< T >() [3/3]

T PeanutButter.DuckTyping.Extensions.DuckTypingDictionaryExtensions.ForceFuzzyDuckAs< T > ( this object src)
static

Forces approximate ducking around a dictionary. Will "create" underlying "properties" as required. Will attempt to convert to and from the underlying types as required. Will match properties case-insensitive.

Parameters
src
Template Parameters
T
Returns

◆ FuzzyDuckAs< T >() [1/6]

T PeanutButter.DuckTyping.Extensions.DuckTypingDictionaryExtensions.FuzzyDuckAs< T > ( this IDictionary< string, object > src,
string keyPrefix )
static

Fuzzy-Ducks a Dictionary (or part thereof) using a key prefix to allow "namespacing" of config.

Parameters
srcIDictionary to operate on
keyPrefixkey prefix to take into account
Template Parameters
TInterface to duck onto
Returns
new instance of T, wrapping the Dictionary, or null if unduckable
Type Constraints
T :class 

◆ FuzzyDuckAs< T >() [2/6]

T PeanutButter.DuckTyping.Extensions.DuckTypingDictionaryExtensions.FuzzyDuckAs< T > ( this IDictionary< string, object > src,
string keyPrefix,
bool throwOnError )
static

Fuzzy-Ducks a Dictionary (or part thereof) using a key prefix to allow "namespacing" of config.

Parameters
srcIDictionary to operate on
keyPrefixkey prefix to take into account
throwOnErrorflag: when unduckable, throw instead of just returning null
Template Parameters
TInterface to duck onto
Returns
new instance of T, wrapping the Dictionary, or null if unduckable
Type Constraints
T :class 

◆ FuzzyDuckAs< T >() [3/6]

T PeanutButter.DuckTyping.Extensions.DuckTypingDictionaryExtensions.FuzzyDuckAs< T > ( this IDictionary< string, object > src,
TransformFunc toNativeTransform,
TransformFunc fromNativeTransform )
static

Performs fuzzy ducking with property name redirection.

Parameters
srcDictionary to duck
toNativeTransformFunc to transform from keys corresponding to T's interface properties to keys that are found in src
fromNativeTransformReverse of toNativeTransform
Template Parameters
TInterface to duck this dictionary as
Returns
New instance of an object implementing T, passing through to the dictionary, or null if unable to duck
Type Constraints
T :class 

◆ FuzzyDuckAs< T >() [4/6]

T PeanutButter.DuckTyping.Extensions.DuckTypingDictionaryExtensions.FuzzyDuckAs< T > ( this IDictionary< string, object > src,
TransformFunc toNativeTransform,
TransformFunc fromNativeTransform,
bool throwOnError )
static

Performs fuzzy ducking with property name redirection.

Parameters
srcDictionary to duck
toNativeTransformFunc to transform from keys corresponding to T's interface properties to keys that are found in src
fromNativeTransformReverse of toNativeTransform
throwOnErrorFlag to throw exception on error instead of just silent failure
Template Parameters
TInterface to duck this dictionary as
Returns
New instance of an object implementing T, passing through to the dictionary, or null if unable to duck
Type Constraints
T :class 

◆ FuzzyDuckAs< T >() [5/6]

T PeanutButter.DuckTyping.Extensions.DuckTypingDictionaryExtensions.FuzzyDuckAs< T > ( this NameValueCollection src,
string keyPrefix )
static

Fuzzy-Ducks a NameValueCollection (or part thereof) using a key prefix to allow "namespacing" of config.

Parameters
srcNameValueCollection to operate on
keyPrefixkey prefix to take into account
Template Parameters
TInterface to duck onto
Returns
new instance of T, wrapping the NameValueCollection, or null if unduckable
Type Constraints
T :class 

◆ FuzzyDuckAs< T >() [6/6]

T PeanutButter.DuckTyping.Extensions.DuckTypingDictionaryExtensions.FuzzyDuckAs< T > ( this NameValueCollection src,
string keyPrefix,
bool throwOnError )
static

Fuzzy-Ducks a NameValueCollection (or part thereof) using a key prefix to allow "namespacing" of config.

Parameters
srcNameValueCollection to operate on
keyPrefixkey prefix to take into account
throwOnErrorflag: when unduckable, throw instead of just returning null
Template Parameters
TInterface to duck onto
Returns
new instance of T, wrapping the NameValueCollection, or null if unduckable
Type Constraints
T :class 

The documentation for this class was generated from the following file:
  • source/Utils/PeanutButter.DuckTyping/Extensions/DuckTypingDictionaryExtensions.cs