c# - Register All Classes Manually or there is an automatic way? -
i using asp.net mvc 5. new autofac. have lot of classes , each class have do,
builder.registertype<authenticationservice>().as<iauthenticationservice>(); builder.registertype<iauthenticationrepositry>().as<authenticationrepositry>(); ............................................................................... ...............................................................................
registering each type time-consuming , quite forget-able. there automatic way register components in autofac?
if want automatically register types as interfaces, can use registerassemblytypes
:
builder.registerassemblytypes(typeof(mvcapplication).assembly).asimplementedinterfaces();
or asself
, if want resolve concrete implementations.
Comments
Post a Comment