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

Shim to wrap objects for ducking. More...

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

Public Member Functions

 ShimSham (object[] toWrap, Type interfaceToMimic, bool isFuzzy, bool allowReadonlyDefaultMembers)
 Constructs a new instance of the ShimSham with a DefaultPropertyInfoFetcher.
 ShimSham (object toWrap, Type interfaceToMimic, bool isFuzzy, bool allowReadonlyDefaultMembers)
 Constructs a new instance of the ShimSham with the provided property info fetcher.
 ShimSham (object[] toWrap, Type interfaceToMimic, bool isFuzzy, bool allowReadonlyDefaultsForMissingMembers, IPropertyInfoFetcher propertyInfoFetcher)
 Constructs a new instance of the ShimSham with the provided property info fetcher.
object GetPropertyValue (string propertyName)
 Gets a property value from the underlying object.
Parameters
propertyNameName of the property to get the value for
Returns
Value of the underlying property

void SetPropertyValue (string propertyName, object newValue)
 Sets a property value on the underlying object.
Parameters
propertyNameName of the property to set
newValueValue to set

void CallThroughVoid (string methodName, params object[] parameters)
 Calls through to an underlying void-returning method.
Parameters
methodNameName of the method to call through to
parametersParameters to pass through to the method

object CallThrough (string methodName, object[] arguments)
 Calls through to an underlying method and returns the result.
Parameters
methodNameName of the method to call through to
argumentsParameters to pass through to the method
Returns
Value returned from the underlying method

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

Shim to wrap objects for ducking.

Constructor & Destructor Documentation

◆ ShimSham() [1/3]

PeanutButter.DuckTyping.Shimming.ShimSham.ShimSham ( object[] toWrap,
Type interfaceToMimic,
bool isFuzzy,
bool allowReadonlyDefaultMembers )

Constructs a new instance of the ShimSham with a DefaultPropertyInfoFetcher.

Parameters
toWrapObjects to wrap (wip: only the first object is considered)
interfaceToMimicInterface type to mimick
isFuzzyFlag allowing or preventing approximation
allowReadonlyDefaultMembersallows properties with no backing to be read as the default value for that type

◆ ShimSham() [2/3]

PeanutButter.DuckTyping.Shimming.ShimSham.ShimSham ( object toWrap,
Type interfaceToMimic,
bool isFuzzy,
bool allowReadonlyDefaultMembers )

Constructs a new instance of the ShimSham with the provided property info fetcher.

Parameters
toWrapObject to wrap
interfaceToMimicInterface type to mimick
isFuzzyFlag allowing or preventing approximation
Exceptions
ArgumentNullExceptionThrown if the mimick interface or property info fetch are null
Parameters
allowReadonlyDefaultMembersallows properties with no backing to be read as the default value for that type

◆ ShimSham() [3/3]

PeanutButter.DuckTyping.Shimming.ShimSham.ShimSham ( object[] toWrap,
Type interfaceToMimic,
bool isFuzzy,
bool allowReadonlyDefaultsForMissingMembers,
IPropertyInfoFetcher propertyInfoFetcher )

Constructs a new instance of the ShimSham with the provided property info fetcher.

Parameters
toWrapObjects to wrap (wip: only the first object is considered)
interfaceToMimicInterface type to mimick
isFuzzyFlag allowing or preventing approximation
allowReadonlyDefaultsForMissingMembersWhether to allow returning default(T) for properties which are missing on the wrapped source(s)
propertyInfoFetcherUtility to fetch property information from the provided object and interface type
Exceptions
ArgumentNullExceptionThrown if the mimick interface or property info fetch are null

Member Function Documentation

◆ CallThrough()

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

Calls through to an underlying method and returns the result.

Parameters
methodNameName of the method to call through to
argumentsParameters to pass through to the method
Returns
Value returned from the underlying method

Implements PeanutButter.DuckTyping.Shimming.IShimSham.

◆ CallThroughVoid()

void PeanutButter.DuckTyping.Shimming.ShimSham.CallThroughVoid ( string methodName,
params object[] parameters )

Calls through to an underlying void-returning method.

Parameters
methodNameName of the method to call through to
parametersParameters to pass through to the method

Implements PeanutButter.DuckTyping.Shimming.IShimSham.

◆ GetPropertyValue()

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

Gets a property value from the underlying object.

Parameters
propertyNameName of the property to get the value for
Returns
Value of the underlying property

Implements PeanutButter.DuckTyping.Shimming.IShimSham.

◆ SetPropertyValue()

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

Sets a property value on the underlying object.

Parameters
propertyNameName of the property to set
newValueValue to set

Implements PeanutButter.DuckTyping.Shimming.IShimSham.


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