AdapterHelper.IsSubstitutableBy Method

Namespace
Kampute.DocToolkit.Metadata.Adapters
Assembly
  • Kampute.DocToolkit.dll

Definition

Determines whether a target type can substitute a source type, where the generic type parameters of a type that appear in the source type, also within arrays, pointers, by-ref and nullable types, or as type arguments of constructed generic types, can be substituted by any type that satisfies their constraints.
public static bool IsSubstitutableBy(IType sourceType, IType targetType)

Parameters

sourceType IType
The type used by the base declaration.
targetType IType
The type used by the derived or implementing declaration.

Returns

bool
true if targetType can substitute sourceType; otherwise, false.

Exceptions

ArgumentNullException
Thrown when sourceType or targetType is null.

Remarks

For example, List<T> of a base declaration can be substituted by List<string> of an overriding declaration when string satisfies the constraints of T. Types that do not involve generic type parameters must be equal.