C# Класс NFluent.Helpers.IsInstanceHelper

Helper class related to Is(Not)Instance methods (used like a traits).
Показать файл Открыть проект

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

Метод Описание
BuildErrorMessage ( object value, Type typeOperand, bool isSameType ) : string

Builds the error message related to the type comparison. This should be called only if the test failed (no matter it is negated or not). Warning: Should not call this method with nullable types. Indeed, the Nullable types are treated specially by CLR and it is impossible to have a boxed instance of a nullable type. Instead, boxing a nullable type will result in a null reference (if HasValue is false), or the boxed value (if there is a value).

BuildErrorMessageForNullable ( Type instanceType, Type expectedType, object value, bool isSameType ) : string
InheritsFrom ( IChecker checker, Type expectedBaseType ) : void

Checks that an instance is in the inheritance hierarchy of a specified type.

IsDifferentType ( Type instanceType, Type expectedType, object value ) : void

Checks that a type is not the expected one.

IsInstanceOf ( object instance, Type expectedType ) : void

Checks that an instance is of the given expected type.

IsNotInstanceOf ( object instance, Type typeNotExpected ) : void

Checks that an instance is not of the given expected type.

IsSameType ( Type instanceType, Type expectedType, object value ) : void

Checks that a type is the same as the expected one.

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

BuildErrorMessage() публичный статический Метод

Builds the error message related to the type comparison. This should be called only if the test failed (no matter it is negated or not). Warning: Should not call this method with nullable types. Indeed, the Nullable types are treated specially by CLR and it is impossible to have a boxed instance of a nullable type. Instead, boxing a nullable type will result in a null reference (if HasValue is false), or the boxed value (if there is a value).
public static BuildErrorMessage ( object value, Type typeOperand, bool isSameType ) : string
value object The checked value.
typeOperand System.Type The other type operand.
isSameType bool A value indicating whether the two types are identical or not. true if they are equal; false otherwise.
Результат string

BuildErrorMessageForNullable() публичный статический Метод

public static BuildErrorMessageForNullable ( Type instanceType, Type expectedType, object value, bool isSameType ) : string
instanceType System.Type
expectedType System.Type
value object
isSameType bool
Результат string

InheritsFrom() публичный статический Метод

Checks that an instance is in the inheritance hierarchy of a specified type.
The instance is not in the inheritance hierarchy of the specified type.
public static InheritsFrom ( IChecker checker, Type expectedBaseType ) : void
checker IChecker The instance to be checked.
expectedBaseType System.Type The Type which is expected to be a base Type of the instance.
Результат void

IsDifferentType() публичный статический Метод

Checks that a type is not the expected one.
public static IsDifferentType ( Type instanceType, Type expectedType, object value ) : void
instanceType System.Type The type of the instance to be checked.
expectedType System.Type The expected type for the instance to be checked.
value object The value of the instance to be checked (may be a nullable instance).
Результат void

IsInstanceOf() публичный статический Метод

Checks that an instance is of the given expected type.
The instance is not of the expected type.
public static IsInstanceOf ( object instance, Type expectedType ) : void
instance object The instance to be checked.
expectedType System.Type The expected type.
Результат void

IsNotInstanceOf() публичный статический Метод

Checks that an instance is not of the given expected type.
The instance is of the type not expected.
public static IsNotInstanceOf ( object instance, Type typeNotExpected ) : void
instance object The instance to be checked.
typeNotExpected System.Type The type not expected.
Результат void

IsSameType() публичный статический Метод

Checks that a type is the same as the expected one.
public static IsSameType ( Type instanceType, Type expectedType, object value ) : void
instanceType System.Type The type of the instance to be checked.
expectedType System.Type The expected type for the instance to be checked.
value object The value of the instance to be checked (may be a nullable instance).
Результат void