AspNet ObjectDataSource and Castle Windsor
I’m restructuring a portion of a site, it is well structured, and all logic is inside business classes in another assembly, and they are accessed with ObjectDataSources. My problem is that with the new structure I cannot refer to the concrete classes anymore, but I need to resolve them with an IoC container, like Castle Windsor.
The solution to this problem was really simple, I created this simple class
|
|
It inherits from the basic ObjectDataSource, but it shadows the TypeName property; in setter part of TypeName it call a IoC wrapper to get the concrete name of the component configured for a given interface. Now I can specify an interface instead of the real type.
|
|
Thanks to Castle Windsor I can easily recover the concrete type registered for a given interface.
|
|
Alk.