*
This commit is contained in:
1 parent
c18fef7074
commit
1f91e757c2
1 file changed
+3
-3
@@ -1,10 +1,10 @@
|
|||||||
namespace MeloongCore.Extensions;
|
namespace MeloongCore;
|
||||||
public static class GeneralExtension {
|
public static class GeneralUtils {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 判断对象是否为指定泛型类型的实例。
|
/// 判断对象是否为指定泛型类型的实例。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static bool IsGenericInstanceOf(this object? instance, Type genericTypeDefinition) {
|
public static bool IsGenericInstanceOf(object? instance, Type genericTypeDefinition) {
|
||||||
if (instance is null) return false;
|
if (instance is null) return false;
|
||||||
for (var type = instance.GetType(); type is not null; type = type.BaseType) {
|
for (var type = instance.GetType(); type is not null; type = type.BaseType) {
|
||||||
if (type.IsGenericType && type.GetGenericTypeDefinition() == genericTypeDefinition) return true;
|
if (type.IsGenericType && type.GetGenericTypeDefinition() == genericTypeDefinition) return true;
|
||||||
Reference in new issue
Block a user