C# Класс DeftTech.DuckTyping.DelegateDuckProxyType

Class that performs the generation of duck proxy types for forwarding delegate calls.
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
CanProxy ( ) : bool

Determines whether a proxy can be generated for the types given in the constructor.

DelegateDuckProxyType ( Type toDelegateType, Type fromDelegateType ) : System

Constructs an object.

Prepare ( ) : void

Prepares by generating the proxy type for the types given in the constructor.

WrapDuck ( Delegate duck ) : Delegate

Calls the static WrapDuck method of the generated proxy type to initialize a new instance of the proxy type with a given duck delegate and return a delegate to its invoke method.

Приватные методы

Метод Описание
GenerateProxyType ( ) : void

If a proxy type has not been generated yet, generates a proxy type that defines a method matching the method signature of the to delegate type given in the constructor which forwards calls to a delegate of the from type given in the constructor.

GetParameterTypes ( ParameterInfo parameters ) : System.Type[]

Utility to create an array of parameter types from an array of parameters.

ImplementInvokeMethod ( TypeBuilder proxyType, FieldInfo duckDelegateField ) : MethodBuilder

Implements the method of the proxy type that invokes the delegate given in its constructor.

Описание методов

CanProxy() публичный Метод

Determines whether a proxy can be generated for the types given in the constructor.
public CanProxy ( ) : bool
Результат bool

DelegateDuckProxyType() публичный Метод

Constructs an object.
public DelegateDuckProxyType ( Type toDelegateType, Type fromDelegateType ) : System
toDelegateType System.Type Type to be casted to.
fromDelegateType System.Type Type of delegate to be casted.
Результат System

Prepare() публичный Метод

Prepares by generating the proxy type for the types given in the constructor.
public Prepare ( ) : void
Результат void

WrapDuck() публичный Метод

Calls the static WrapDuck method of the generated proxy type to initialize a new instance of the proxy type with a given duck delegate and return a delegate to its invoke method.
public WrapDuck ( Delegate duck ) : Delegate
duck System.Delegate Duck delegate that the new proxy object should forward calls to.
Результат System.Delegate