http://ayende.com/Blog/archive/2008/10/05/windsor-ihandlerselector.aspx

Tuna Toksöz
Eternal sunshine of the open source mind.

http://devlicio.us/blogs/tuna_toksoz
http://tunatoksoz.com
http://twitter.com/tehlike




On Sun, Sep 27, 2009 at 12:36 AM, browns <kelly.brownsber...@gmail.com>wrote:

>
> Hey all - I'm trying to determine how to make Windsor resolve a
> specific implementation based on run-time state.  Nothing in the core
> API is jumping out at me and I'm not sure which of the many
> extensibility points I should pursue.
>
> Does anyone have any advice on how to make these three tests pass?
>
>    [TestFixture]
>    public class Fixture
>    {
>        [RowTest]
>        [Row(typeof(OneProcessor), Mode.One)]
>        [Row(typeof(TwoProcessor), Mode.Two)]
>        [Row(typeof(ThreeProcessor), Mode.Three)]
>        public void Can_Resolve_Processor_By_Mode(Type type, Mode
> mode)
>        {
>            IWindsorContainer factory = new WindsorContainer();
>            factory.AddComponent<IProcessor, OneProcessor>("1");
>            factory.AddComponent<IProcessor, TwoProcessor>("2");
>            factory.AddComponent<IProcessor, ThreeProcessor>("3");
>            factory.AddComponent<Controller>("controller");
>
>            IDictionary dictionary = new Dictionary<string, object>
> {{"mode", mode}};
>
>            Controller controller = factory.Resolve<Controller>
> (dictionary);
>
>            Assert.IsInstanceOfType(type, controller.Processor, "The
> processor didn't resolve to the expected type");
>            Assert.AreEqual(mode, controller.Mode, "The mode was not
> injected into the controller as expected");
>        }
>
>        public enum Mode
>        {
>            One,
>            Two,
>            Three
>        }
>
>        public class Controller
>        {
>            private readonly IProcessor _processor;
>            private readonly Mode _mode;
>
>            public Controller(Mode mode, IProcessor processor)
>            {
>                _mode = mode;
>                _processor = processor;
>            }
>
>            public IProcessor Processor { get { return _processor; } }
>
>            public Mode Mode { get { return _mode; } }
>        }
>
>        public interface IProcessor { }
>
>        public class OneProcessor : IProcessor {}
>
>        public class TwoProcessor : IProcessor {}
>
>        public class ThreeProcessor : IProcessor { }
>    }
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to castle-project-users@googlegroups.com
To unsubscribe from this group, send email to 
castle-project-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to