C# 如何从类类型解析泛型接口

C# 如何从类类型解析泛型接口,c#,autofac,C#,Autofac,我在配置Autofac模块时遇到一个小问题。我想用命令模式解析IValidator(Fluent Validator)服务,但我不知道如何解析 以下是我的命令: public interface ICommand public interface ICreateCommand<TDto> : where TDto is IDto public CreateUserCommand : ICreateCommand<UserDto> AbstractValidator是

我在配置Autofac模块时遇到一个小问题。我想用命令模式解析IValidator(Fluent Validator)服务,但我不知道如何解析

以下是我的命令:

public interface ICommand

public interface ICreateCommand<TDto> : where TDto is IDto

public CreateUserCommand : ICreateCommand<UserDto>

AbstractValidator是否继承IValidator

基本上我注册的类型如下:

var types = assembly.GetTypes().Where( t => t.IsClosedTypeOf( typeof( IValidator<> ) ) );
var types=assembly.GetTypes()。其中(t=>t.IsClosedTypeOf(typeof(ivalidotor));

我有小提琴。也许您可以在那里找到解决方案

AbstractValidator继承了IValidator吗

基本上我注册的类型如下:

var types = assembly.GetTypes().Where( t => t.IsClosedTypeOf( typeof( IValidator<> ) ) );
var types=assembly.GetTypes()。其中(t=>t.IsClosedTypeOf(typeof(ivalidotor));
我有小提琴。也许你可以在那里找到解决办法

var types = assembly.GetTypes().Where( t => t.IsClosedTypeOf( typeof( IValidator<> ) ) );