Factory method with Windsor

5 views
Skip to first unread message

Darren Cauthon

unread,
Jun 27, 2010, 6:41:40 PM6/27/10
to mvctu...@googlegroups.com

Hey everybody, I wanted to throw this out in case someone with more experience and understanding with Windsor can provide a quick answer.  I had an idea last week:  Add factory method registration to  the CSL.  It's something that all of the supported IoC containers provide, and I think it's something that could keep developers from having to pick a specific IoC container during development.  I was able to get it to work with Unity, StructureMap, Ninject, and Autofac.  Castle Windsor is a different matter.  I've tried a number of things, but I always seem to get a fail when I resolve.  

I've included a link to the registration line in the CSL below.  I've also included my Register method in case that helps.  Any ideas?


        public void Register<Interface>(Func<Interface> factoryMethod) where Interface : class
        {
            var registration = Component.For<Interface>()
                .UsingFactoryMethod(factoryMethod.Invoke);
            registrationList.Add(registration);
        }



Darren Cauthon
dar...@cauthon.com
(913) 712-9648

Reply all
Reply to author
Forward
0 new messages