PeanutButter
Loading...
Searching...
No Matches
PeanutButter.DuckTyping.Shimming.DictionaryShimSham Class Reference

Provides the required shimming to duck a dictionary object to an interface. More...

Inheritance diagram for PeanutButter.DuckTyping.Shimming.DictionaryShimSham:
PeanutButter.DuckTyping.Shimming.ShimShamBase PeanutButter.DuckTyping.Shimming.IShimSham

Public Member Functions

 DictionaryShimSham (IDictionary< string, object > toWrap, Type typeToMimic)
 Constructs an instance of the DictionaryShimSham.
 DictionaryShimSham (IDictionary< string, object >[] toWrap, Type typeToMimic)
 Constructs an instance of the DictionaryShimSham.
object GetPropertyValue (string propertyName)
 Gets the value of a property by name.
void SetPropertyValue (string propertyName, object newValue)
 Attempts to set the value of the named property.
void CallThroughVoid (string methodName, params object[] arguments)
 Required to implement the IShimSham interface, but not implemented for dictionaries as the concept doesn't make sense.
object CallThrough (string methodName, object[] arguments)
 Required to implement the IShimSham interface, but not implemented for dictionaries as the concept doesn't make sense.

Additional Inherited Members

Static Public Member Functions inherited from PeanutButter.DuckTyping.Shimming.ShimShamBase
static object GetDefaultValueFor (Type correctType)
 Gets the default value for a type.
Protected Member Functions inherited from PeanutButter.DuckTyping.Shimming.ShimShamBase
object ConvertWith (IConverter converter, object propValue, Type toType)
 Converts a property value from original type to another type using the provided converter.
Type MakeTypeToImplement (Type type, bool isFuzzy)
 Creates a new type to implement the requested interface type Used internally when fleshing out non-primitive properties.

Detailed Description

Provides the required shimming to duck a dictionary object to an interface.

Constructor & Destructor Documentation

◆ DictionaryShimSham() [1/2]

PeanutButter.DuckTyping.Shimming.DictionaryShimSham.DictionaryShimSham ( IDictionary< string, object > toWrap,
Type typeToMimic )

Constructs an instance of the DictionaryShimSham.

Parameters
toWrapDictionary to wrap
typeToMimicInterface that must be mimicked

◆ DictionaryShimSham() [2/2]

PeanutButter.DuckTyping.Shimming.DictionaryShimSham.DictionaryShimSham ( IDictionary< string, object >[] toWrap,
Type typeToMimic )

Constructs an instance of the DictionaryShimSham.

Parameters
toWrapDictionaries to wrap (wip: only the first is considered)
typeToMimicInterface that must be mimicked

Member Function Documentation

◆ CallThrough()

object PeanutButter.DuckTyping.Shimming.DictionaryShimSham.CallThrough ( string methodName,
object[] arguments )

Required to implement the IShimSham interface, but not implemented for dictionaries as the concept doesn't make sense.

Parameters
methodNameName of the method to not call through to
argumentsParameters to ignore
Exceptions
NotImplementedExceptionException which is always thrown

Implements PeanutButter.DuckTyping.Shimming.IShimSham.

◆ CallThroughVoid()

void PeanutButter.DuckTyping.Shimming.DictionaryShimSham.CallThroughVoid ( string methodName,
params object[] arguments )

Required to implement the IShimSham interface, but not implemented for dictionaries as the concept doesn't make sense.

Parameters
methodNameName of the method to not call through to
argumentsParameters to ignore
Exceptions
NotImplementedExceptionException which is always thrown

Implements PeanutButter.DuckTyping.Shimming.IShimSham.

◆ GetPropertyValue()

object PeanutButter.DuckTyping.Shimming.DictionaryShimSham.GetPropertyValue ( string propertyName)

Gets the value of a property by name.

Parameters
propertyNameName of the property to get the value of
Returns
The value of the property, where possible. May return the default value for the property type when it is not found and may attempt automatic conversion when the type to represent does not match the underlying type

Implements PeanutButter.DuckTyping.Shimming.IShimSham.

◆ SetPropertyValue()

void PeanutButter.DuckTyping.Shimming.DictionaryShimSham.SetPropertyValue ( string propertyName,
object newValue )

Attempts to set the value of the named property.

Parameters
propertyNameName of the property to set
newValueValue to set. The value may be converted to match the underlying type when required.

Implements PeanutButter.DuckTyping.Shimming.IShimSham.


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