Am I doing this right? Looking at the source, it seems that the configure extension function calls ServiceCollection.AddInstance so I'd be able to use the class for DI?
startup.cs:
publicvoid ConfigureServices(IServiceCollection services)
{
services.Configure<SiteSettings>(settings =>{
settings.BlobStorageConnectionString = Configuration.Get("BlobStorageConnectionString");
settings.BlobEndpoint = Configuration.Get("BlobEndpoint");
});
....
Controller:
namespace GearUp.Controllers.Controllers
{
[Route("api/[controller]")]
publicclassUploadImageController : Controller
{
privatereadonlyCloudStorageAccount _storageAccount;
public UploadImageController(SiteSettings settings)
{
this._storageAccount = CloudStorageAccount.Parse(settings.BlobStorageConnectionString);
}
.....
when I make an ajax call to the webapi controller I get a 500 error with the message:
InvalidOperationException: Unable to resolve service for type 'GearUp.SiteSettings' while attempting to activate 'GearUp.Controllers.Controllers.UploadImageController'
Thanks!