Open sandboxFocus

Method MustBeInstanceOfType

MustBeInstanceOfType<T>(IEligibilityBuilder<T>, Type)

Requires the validated object to be of a certain type of metadata object, e.g. an IField or IMethod. To check the type of a field, property or parameter, use code like builder.Type().MustBe(typeof(string)); instead.

Declaration
public static void MustBeInstanceOfType<T>(this IEligibilityBuilder<T> eligibilityBuilder, Type type) where T : class
Parameters
Type Name Description
IEligibilityBuilder<T> eligibilityBuilder
Type type
Type Parameters
Name Description
T
Remarks

Note that this validates the object itself, not the declaration that it represents. For instance, if the object is an IParameter and the type parameter is set to typeof(string), this method will fail with an exception, because no conversion exists from IParameter to string.

On the other hand, code like builder.MustBeOfType(typeof(IProperty)); will correctly check that a declaration is a property.