You can but since c# doesn't support that your factory method would have
to do some reflection.
@K
On 12/05/2012 4:27 AM, npinski wrote:
Hi there,
Is there a way to register a WindsorContainer to resolve a generic
type using a generic factory method?
I know I can do registration like:
Component.For<IMyService>().ImplementedBy<MyServiceImpl>()
and
Component.For<MyObject>().UsingFactoryMethod(MyObjectFactory.Create)
and even
Component.For(typeof(IMyGenericService<>)).ImplementedBy(typeof(MyGenericServiceImpl<>))
what I'm looking for is something like:
Component.For(typeof(MyGenericObject<>)).UsingFactoryMethod(MyGenericObjectFactory.Create<>())
Is there a way to do this in a clean way? I started peripherally
reading about IGenericImplementationMatchingStrategy, and Typed
Factory Facilities, but this seems like overkill for what I'm doing.
The workaround I have right now is to create a wrapper for
MyGenericObject<>, and have an interface for the wrapper, which I can
then register with the aforementioned syntax
Component.For(typeof(IMyGenericService<>)).ImplementedBy(typeof(MyGenericServiceImpl<>))
Thanks in advance, guys!
--
You received this message because you are subscribed to the Google Groups "Castle
Project Development List" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/castle-project-devel?hl=en.