Post.Cast<TSource, TTarget> Method
At post-compile time, casts an instance of a type into another.
A post-compile time error is reported if the source type cannot be
assigned to the target type.
PostSharp (in PostSharp.dll) Version: 184.108.40.206 (220.127.116.11)
public static TTarget Cast<TSource, TTarget>(
where TSource : class
where TTarget : class
- Type: TSource
Instance to be casted.
- Source type.
- Target type.
The object o
casted as TTarget
The purpose of this method is to make a source code compilable even when
an interface will be implemented at post-compile time.
PostSharp ensures that TTarget is assignable from
TSource. If yes, the call to this method is
simply suppressed. If types are not assignable, a build error is issued.