我有一个要从主控制台应用程序引用的类库项目(我正在使用的类是#include<stdio.h>
double pow(); //traditional declaration doesnt work, why??
int main()
{
printf("pow(2, 3) = %g", pow(2, 3));
return 0;
}
)。
如果构造函数仅将ILogger作为这样的参数:
ProcessService
然后我像这样在public ProcessService(ILogger factory)
{
}
中注册它:
ConfigureServices(IServiceCollection services)
工作正常。问题是我需要传递另一个参数,然后ILogger传递我从appsettings中获取的另一个参数,因此该类的构造函数如下所示:
services.AddSingleton<IProcessService, ProcessService>();
然后我试图像这样注册它:
public ProcessService(int period,ILogger factory){}
但是我必须通过一个初始化的记录器,并且它不正确。 达到我的要求的方式是什么?