zcz527 / autofac

Automatically exported from code.google.com/p/autofac
Other
0 stars 0 forks source link

Add RegisterAssemblyTypes overload which gets a list of types #305

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
In the first look that looks like not a good idea since this would not do what 
the function name is.

The problem is a module which uses RegisterAssemblyTypes can not be good unit 
tested since i can not inject the types from my test assembly there. So most of 
my modules accept an error of types. The problem with it is that i the only way 
to register it is to call builder.RegisterType under an foreach loop which 
looks really really ugly. 

Maybe a good alternative could be to add an RegisterTypes. Or a way for tests 
to change what RegisterAssemblyTypes will found.

Original issue reported on code.google.com by lanwin...@gmail.com on 3 Mar 2011 at 1:38

GoogleCodeExporter commented 8 years ago
Thanks for the suggestion. RegisterTypes() is the way to go. I'd held off on 
this because the extra surface area doesn't seem justified when compared with 
the small amount of code required to do this by hand. Looking at it now though 
it does make an improvement to the consistency of registration code so we 
should include it.

Original comment by nicholas...@gmail.com on 9 Mar 2011 at 9:40

GoogleCodeExporter commented 8 years ago
What about Removing RegisterAssemblyTypes and make an RegisterTypes overload 
which receives an params array of assemblies?

Original comment by lanwin...@gmail.com on 9 Mar 2011 at 9:47

GoogleCodeExporter commented 8 years ago
Nicholas, I guess, lanwin wants more functionality from RegisterTypes method, 
than simply doing RegisterType for each type in the list. He wants to get 
IRegistrationBuilder<object, ScanningActivatorData, DynamicRegistrationStyle> 
as a result from this method to customize all these types as one registration. 

And it seems not so easy to implement by hand looking on how 
RegisterAssemblyTypes is implemented: it would require all of the code from 
ScanningRegistrationExtensions except for the line "assemblies.SelectMany(a => 
a.GetTypes()", which is replaced with simply "types".

Original comment by mrdont@mail.ru on 23 Mar 2011 at 6:42

GoogleCodeExporter commented 8 years ago
Maybe that could be better solved via #332

Original comment by lanwin...@gmail.com on 23 Jun 2011 at 9:15

GoogleCodeExporter commented 8 years ago

Original comment by travis.illig on 21 Sep 2012 at 4:31

GoogleCodeExporter commented 8 years ago

Original comment by travis.illig on 5 Dec 2012 at 6:31

GoogleCodeExporter commented 8 years ago
I think a RegisterTypes option that takes a list of types rather than a list of 
assemblies would be pretty easy to provide and wouldn't conflict with 
RegisterAssemblyTypes. I'll add it.

Original comment by travis.illig on 5 Dec 2012 at 6:34

GoogleCodeExporter commented 8 years ago
This issue was closed by revision dbc6235acdf6.

Original comment by travis.illig on 5 Dec 2012 at 6:49