TypeExtensionsInheritsFrom Method (Type, Type) |
Namespace:
Xcalibur.Extensions
Assembly:
Xcalibur.Extensions (in Xcalibur.Extensions.dll) Version: 1.0.4.0 (1.0.0.0)
Syntax public static bool InheritsFrom(
this Type type,
Type targetType
)
<ExtensionAttribute>
Public Shared Function InheritsFrom (
type As Type,
targetType As Type
) As Boolean
public:
[ExtensionAttribute]
static bool InheritsFrom(
Type^ type,
Type^ targetType
)
[<ExtensionAttribute>]
static member InheritsFrom :
type : Type *
targetType : Type -> bool
Parameters
- type
- Type: SystemType
The type. - targetType
- Type: SystemType
Type of the target.
Return Value
Type:
BooleanUsage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type
Type. When you use instance method syntax to call this method, omit the first parameter. For more information, see
Extension Methods (Visual Basic) or
Extension Methods (C# Programming Guide).
Examples 1var context = ((FrameworkElement)e.OriginalSource).DataContext;
2if (!context.GetType().InheritsFrom<IMyInterface>())
3{
4 e.Handled = true;
5}
6else
7{
8 ViewModel.ContextMenuOpening(context as IMyInterface);
9}
See Also