Coerces a source delegate to a target delegate type by casting the source delegate's
parameters individually to the target delegate type's parameter types.
Namespace:
Gallio.Common.ReflectionAssembly: Gallio (in Gallio.dll) Version: 3.3.0.0 (3.3.610.0)
Syntax
| C# |
|---|
public static Delegate CoerceDelegate( Type targetDelegateType, Delegate sourceDelegate ) |
| Visual Basic (Declaration) |
|---|
Public Shared Function CoerceDelegate ( _ targetDelegateType As Type, _ sourceDelegate As Delegate _ ) As Delegate |
Parameters
- targetDelegateType
- Type: System..::.Type
The target delegate type.
- sourceDelegate
- Type: System..::.Delegate
The source delegate, or null.
Return Value
The target delegate, or null if the source delegate was null.
Exceptions
| Exception | Condition |
|---|---|
| System..::.ArgumentNullException | Thrown if targetDelegateType is null. |
| System..::.ArgumentException | Thrown if targetDelegateType is not a delegate type. |
| System..::.InvalidOperationException | Thrown if the source and target delegate types are incompatible such as if they have different numbers of parameters or a different composition of out/ref parameters. |
