我有一类安装程序类型,其中 TModel 有一个约束。我想创建一个带有类型签名的扩展方法:\
public static void DoRepetitiveStuff<TOtherObject, TModel>(this Installer<TModel> installer)
where TModel : class, IConstraint, new()
where TOtherObject : class, IOtherConstraint, new()
{
installer.DoSomeStuff<TOtherObject>(c => { });
}
目标是最终我可以使用简单的函数调用该函数installer.DoRepetitiveStuff<TOtherObject>();
出于某种原因,当我在另一个文件上调用该函数时。它抱怨没有任何扩展方法可以接受现有的安装程序......我需要将它用于:
installer.DoRepetitiveStuff<TOtherObject, TModel>();
任何人都知道为什么?