c# - Registering multiple objects with same interface in Autofac -
i'm calling below code in xyzmanager
class's constructor , application working.
var handlers = new itabletype[] { new abchandler(new logger(), new repository()), new otherhandler(new logger(), new repository()) /*etc...*/ };
xyzmanager
, logger
, repository
registered in application using autofac.
the problem have around 25 handlers when go live , way have more maintainable code...
i hope have been able explain problem.
edit: know how register handlers in autofac , changes need make above code..
i guess register every handler :
builder.registertype<abchandler>().as<itabletype>()
but how change xyzmanager class's constructor
after register implementors of itabletype
, can define constructor so...
public xyzmanager(itabletype[] handlers, /* other params... */) { }
and autofac give array 1 of each of registered itabletype
objects.
Comments
Post a Comment