我需要在CQRS Mediator中使用通用INotification
。
我使用以下代码:
public class CreateCommand : INotification<OperationResult<CreateCommand>>
{
public string email;
public CreateCommand( string email)
{
this.email = email;
}
}
public interface INotification<TEntity> : INotification
{
}
,在INotificationHandler
中,我需要使用它:
INotificationHandler<OperationResult<CreateCommand>>
代码:
public class CreateUserActivetionCodeCommandHandler :
INotificationHandler<OperationResult<CreateCommand>>
{
private readonly IEFDapperRepository<UserActivetionCode> repository;
private readonly IEmailService email;
public CreateUserActivetionCodeCommandHandler(
IEFDapperRepository<UserActivetionCode> repository, IEmailService email)
{
this.repository = repository;
this.email = email;
}
}
但是它显示了这个错误:
严重性代码说明项目文件行抑制状态抑制状态 错误CS0311类型“ Travel.Common.Operation.OperationResult”不能用作通用类型或方法“ INotificationHandler”中的类型参数“ TNotification”。没有从“ Travel.Common.Operation.OperationResult”到“ MediatR.INotification”的隐式引用转换。 Travel.Services E:\ MyProject \ Trello \ Travel.Services \ UserActivetionCodeService \ Command \ Create \ CreateUserActivetionCodeCommandHandler.cs 16有效
出什么问题了?