源生成器替代反射

This commit is contained in:
snltty
2024-10-10 22:17:28 +08:00
parent f5aa996516
commit 5c83a2f97b
63 changed files with 375 additions and 239 deletions

View File

@@ -1,32 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
namespace linker.libs
{
public sealed class ReflectionHelper
{
public static IEnumerable<Type> GetInterfaceSchieves(Type type)
{
return GetInterfaceSchieves(AppDomain.CurrentDomain.GetAssemblies(), type);
}
/*
public static IEnumerable<Type> GetInterfaceSchieves(Assembly[] assemblys, Type type)
{
return assemblys.SelectMany(c => c.GetTypes())
.Where(c => !c.IsAbstract).Where(c => c.GetInterfaces().Contains(type));
}
public static IEnumerable<Type> GetSubClass(Assembly[] assemblys, Type type)
{
return assemblys.SelectMany(c => c.GetTypes())
.Where(c => !c.IsAbstract).Where(c => c.IsSubclassOf(type));
}
public static IEnumerable<Type> GetEnums(Assembly[] assemblys)
{
return assemblys.SelectMany(c => c.GetTypes())
.Where(c => c.IsEnum);
}
*/
}
}