获取实现某个抽象类的所有类
我正在尝试获取实现某个抽象类的所有类。 我正在尝试使用以下代码执行此操作:
var type = typeof(BaseViewComponent); var types = Assembly .GetEntryAssembly() .GetReferencedAssemblies() .Select(Assembly.Load) .SelectMany(s => s.GetTypes()) .Where(p => type.IsAssignableFrom(p));
但到目前为止,我只能自己获得抽象类。 不是任何实现该基类的类。
我需要更改什么才能获得实现此抽象基类的所有类?
using System.Reflection; using Microsoft.Extensions.DependencyModel;
var asmNames = DependencyContext.Default.GetDefaultAssemblyNames(); var type = typeof(BaseViewComponent); var allTypes = asmNames.Select(Assembly.Load) .SelectMany(t => t.GetTypes()) .Where(p => p.GetTypeInfo().IsSubclassOf(type));
- 在EF Core中添加一对一关系时迁移数据?
- 在.Net Core中使用app.config
- 如何将AcquireTokenAsync中收到的令牌与Active Directory一起存储
- 应用程序在添加Oauth时重定向到Account / AccessDenied
- Apache Ignite.NET SQL不搜索非英文字符
- 是否支持.NET Core中的Microsoft.AspNet.WebApi.Client?
- 如何在aspnet.core web api中validationJWT令牌?
- Swashbuckle.AspNetCore v1.0.0 with OAuth2,flow:application – > IdentityServer4
- 如何在#if语句中设置.NET Core以进行编译