Please see the code below:
var services = new ServiceCollection() .AddTransient<OtherService, OtherService>() .AddTransient<ProductService, ProductService>(sp => { Guid Id = Guid.Parse(configuration["Id"]); return new Product(Id, new OtherService()); } This works as expected. Is it possible to do something like this:
var services = new ServiceCollection() .AddTransient<OtherService, OtherService>() .AddTransient<ProductService, ProductService>(sp => { var otherService = GetService<OtherService>(); Guid Id = Guid.Parse(configuration["Id"]); return new Product(Id, otherService); } What is the proper way of doing this? It is a .NET Core console app.