-
-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make Configuration.AddServices public #54
Comments
Why don't you register these services with the container directly?
The collection is not necessarily and only adds overhead.
|
For example, to set up Microsoft health checks it is necessary to call their extension method I agree if I could just pass the container to that method it would be best, but I don't see any other way to do that. Is there a better way I'm missing? |
You might do in Config class in virtual override.
Adding a method to register more collections is trivial but I might not get to it until late September
|
I'm facing the same issue, you've written an really nice library, with a really good structure. Now that I'm upgrading from the For which I would also need to copy paste the |
Could you provide me with a sample of how you want it to be used? Perhaps couple of different scenarios? I'd like to make sure I understand it correctly. |
Our scenario has similar behavior as this packages use of services
.AddScoped<IMyDependency, MyDependency>()
.AddTransient<IOperationTransient, Operation>()
.AddScoped<IOperationScoped, Operation>()
.AddSingleton<IOperationSingleton, Operation>()
.AddSingleton<IOperationSingletonInstance>(new Operation(Guid.Empty)); (As far as I can see that's the same way this package is using the And because you've already written that "plumbing" for this perfectly it would be a waste to rewrite the exact same behavior. |
What stops you from doing this? public void ConfigureServices(IServiceCollection services)
{
services
.AddScoped<IMyDependency, MyDependency>()
.AddTransient<IOperationTransient, Operation>()
.AddScoped<IOperationScoped, Operation>()
.AddSingleton<IOperationSingleton, Operation>()
.AddSingleton<IOperationSingletonInstance>(new Operation(Guid.Empty));
} Unity supports normal initialization provided in Startup.cs |
When using this for non web applications such as console applications this would be usefull :) |
We have an existing ASP.NET (not Core) app which is using Unity container for DI. However we would like to add some new Microsoft services such as health checks which require an
IServiceCollection
to configure.It would be very helpful if I could create a
ServiceCollection
, add the new Microsoft services, and then populate an existing Unity container with those services. (This seems to be the same request as #23 and/or #24 which were closed by the submitter w/o comment).It looks like
IUnityContainer AddServices(this IUnityContainer container, IServiceCollection services)
inConfiguration.cs
does exactly this, but it's currentlyinternal
. Is there any reason to not make itpublic
?I can currently create a
ServiceProviderFactory
then callCreateBuilder
but that does not allow me to re-use the Unity container I already have.The text was updated successfully, but these errors were encountered: