Reputation: 3129
The client which I am calling looks like this
public class CmsClient : ICmsClient
{
private readonly HttpClient _client;
private readonly ICmsSettings _cmsSettings;
public CmsClient(HttpClient client, ICmsSettings cmsSettings)
{
_client = client;
_cmsSettings = cmsSettings;
}
}
In NInjectWebCommon.cs file I am resolving like this.
kernel.Bind<ICmsClient>().To<CmsClient>()
This is not working as the constructor is expecting httpClient and cmsSetting class. How can I resolve this?
Upvotes: 3
Views: 185
Reputation: 25370
You need to tell your kernel how to resolve those types -
kernel.Bind<ICmsClient>().To<CmsClient>();
kernel.Bind<ICmsSettings>().To<CmsSettings>();
kernel.Bind<HttpClient>().ToSelf();
var client = kernel.Get<ICmsClient>();
Upvotes: 3