方法签名不匹配委托?

时间:2014-09-17 02:57:12

标签: c#

我有这堂课:

public abstract class Effect<TAffectable, TOwner, TInvoker, TLog>
    where TAffectable : IAffectable
    where TOwner : IOwner
    where TInvoker : IInvoker
    where TLog : ILog, new()
{
    public delegate void AdditionalActions(
        TAffectable affectable,
        Effect<TAffectable, IOwner, IInvoker, ILog> effect
    );

    public AdditionalActions AdditionalPreActions { get; set; }
}

此课程正在尝试设置AdditionalPreActions的{​​{1}}属性:

Effect

但是我收到了一个编译错误 public abstract class Command<TEffect, TAffectable, TOwner, TInvoker, TLog> where TEffect : Effect<TAffectable, TOwner, TInvoker, TLog> where TAffectable : IAffectable where TOwner : IOwner where TInvoker : IInvoker where TLog : ILog, new() { public List<TEffect> Effects { get; set; } protected virtual void CommandPreActions(TAffectable affectable, TEffect effect) { } public virtual void Execute(TAffectable affectable) { Effects.ForEach(e => e.AdditionalPreActions = CommandPreActions); //Do stuff } }

错误说:

  

没有超载&#39; CommandPreActions&#39;匹配委托&#39; Effect.AdditionalActions&#39;

但看起来我的所有泛型类型都已正确定义。

0 个答案:

没有答案