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

Provides duck-typing around NameValueCollections. More...

Static Public Member Functions

static T DuckAs< T > (this NameValueCollection src)
 Ducks a NameValueCollection onto an interface.
static T DuckAs< T > (this NameValueCollection src, bool throwOnError)
 Ducks a NameValueCollection onto an interface.
static T FuzzyDuckAs< T > (this NameValueCollection src)
 Fuzzy-Ducks a NameValueCollection onto an interface, not caring about case or whitespace in property names.
static T FuzzyDuckAs< T > (this NameValueCollection src, bool throwOnError)
 Fuzzy-Ducks a NameValueCollection onto an interface, not caring about case or whitespace in property names.
static T ForceDuckAs< T > (this NameValueCollection src)
 Forces ducking onto the NameValueCollection. Missing properties return default values when queried and can be set with new values.
static T ForceFuzzyDuckAs< T > (this NameValueCollection src)
 Forces fuzzy ducking onto the NameValueCollection. Missing properties return default values when queried and can be set with new values.
static T DuckAs< T > (this NameValueCollection src, TransformFunc toNativeTransform, TransformFunc fromNativeTransform)
 Performs ducking with property name redirection.
static T DuckAs< T > (this NameValueCollection src, TransformFunc toNativeTransform, TransformFunc fromNativeTransform, bool throwOnError)
 Performs ducking with property name redirection.
static T FuzzyDuckAs< T > (this NameValueCollection src, TransformFunc toNativeTransform, TransformFunc fromNativeTransform)
 Performs fuzzy ducking with property name redirection.
static T FuzzyDuckAs< T > (this NameValueCollection src, TransformFunc toNativeTransform, TransformFunc fromNativeTransform, bool throwOnError)
 Performs fuzzy ducking with property name redirection.

Detailed Description

Provides duck-typing around NameValueCollections.

Member Function Documentation

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

T PeanutButter.DuckTyping.Extensions.DuckTypingNameValueCollectionExtensions.DuckAs< T > ( this NameValueCollection src)
static

Ducks a NameValueCollection onto an interface.

Parameters
srcNameValueCollection to operate on
Template Parameters
TInterface you wish to work through
Returns
New instance of an object implementing the required interface, if possible; otherwise null
Type Constraints
T :class 

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

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

Ducks a NameValueCollection onto an interface.

Parameters
srcNameValueCollection to operate on
throwOnErrorFlag: throw an exception instead of just returning null
Template Parameters
TInterface you wish to work through
Returns
New instance of an object implementing the required interface
Type Constraints
T :class 

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

T PeanutButter.DuckTyping.Extensions.DuckTypingNameValueCollectionExtensions.DuckAs< T > ( this NameValueCollection 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/4]

T PeanutButter.DuckTyping.Extensions.DuckTypingNameValueCollectionExtensions.DuckAs< T > ( this NameValueCollection 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 

◆ ForceDuckAs< T >()

T PeanutButter.DuckTyping.Extensions.DuckTypingNameValueCollectionExtensions.ForceDuckAs< T > ( this NameValueCollection src)
static

Forces ducking onto the NameValueCollection. Missing properties return default values when queried and can be set with new values.

Parameters
srcNameValueCollection to operate on
Template Parameters
TInterface to duck to
Returns
New instance of an object implementing the required interface, if possible

◆ ForceFuzzyDuckAs< T >()

T PeanutButter.DuckTyping.Extensions.DuckTypingNameValueCollectionExtensions.ForceFuzzyDuckAs< T > ( this NameValueCollection src)
static

Forces fuzzy ducking onto the NameValueCollection. Missing properties return default values when queried and can be set with new values.

Parameters
srcNameValueCollection to operate on
Template Parameters
TInterface to duck to
Returns
New instance of an object implementing the required interface, if possible

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

T PeanutButter.DuckTyping.Extensions.DuckTypingNameValueCollectionExtensions.FuzzyDuckAs< T > ( this NameValueCollection src)
static

Fuzzy-Ducks a NameValueCollection onto an interface, not caring about case or whitespace in property names.

Parameters
srcNameValueCollection to operate on
Template Parameters
TInterface you wish to work through
Returns
New instance of an object implementing the required interface, if possible; otherwise null
Type Constraints
T :class 

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

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

Fuzzy-Ducks a NameValueCollection onto an interface, not caring about case or whitespace in property names.

Parameters
srcNameValueCollection to operate on
throwOnErrorFlag: throw an exception if cannot duck instead of just returning null
Template Parameters
TInterface you wish to work through
Returns
New instance of an object implementing the required interface, if possible
Type Constraints
T :class 

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

T PeanutButter.DuckTyping.Extensions.DuckTypingNameValueCollectionExtensions.FuzzyDuckAs< T > ( this NameValueCollection 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/4]

T PeanutButter.DuckTyping.Extensions.DuckTypingNameValueCollectionExtensions.FuzzyDuckAs< T > ( this NameValueCollection 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 

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