From ab07c2bff92d084816f1670528b79b8c7a889a9b Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Tue, 25 Dec 2018 15:46:56 +0300 Subject: [PATCH] Add AbpTypeExtensions.IsAssignableTo. --- .../Volo.Abp.Core/System/AbpTypeExtensions.cs | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/framework/src/Volo.Abp.Core/System/AbpTypeExtensions.cs b/framework/src/Volo.Abp.Core/System/AbpTypeExtensions.cs index 7742998c13..a90e4212e1 100644 --- a/framework/src/Volo.Abp.Core/System/AbpTypeExtensions.cs +++ b/framework/src/Volo.Abp.Core/System/AbpTypeExtensions.cs @@ -6,5 +6,30 @@ { return type.FullName + ", " + type.Assembly.GetName().Name; } + + /// + /// Determines whether an instance of this type can be assigned to + /// an instance of the . + /// + /// Internally uses . + /// + /// Target type (as reverse). + public static bool IsAssignableTo(this Type type) + { + return type.IsAssignableTo(typeof(TTarget)); + } + + /// + /// Determines whether an instance of this type can be assigned to + /// an instance of the . + /// + /// Internally uses (as reverse). + /// + /// this type + /// Target type + public static bool IsAssignableTo(this Type type, Type targetType) + { + return targetType.IsAssignableFrom(type); + } } }