CarterCommunity / Carter

Carter is framework that is a thin layer of extension methods and functionality over ASP.NET Core allowing code to be more explicit and most importantly more enjoyable.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ICarterModule as Singleton services?

KevinValmo opened this issue · comments

Hello.

This could be a discussion or a feature that could be added or not...

I was thinking about "old" Controllers and ControllerBases on the Mvc namespace.
As the "old" Controllers are by default transient service (not always), don't you think to preserve this behaviur by adding to Services the ICarterModules as transient?
Isn't it better to mark modules as transient lifetime services?
Or it could be better maybe to let devs configure the lifetime of those ICarterModules service within an implementation of a ICarterModuleFactory or somethig else.

foreach (var newModule in newModules)
{
services.AddSingleton(typeof(ICarterModule), newModule);
}