Devlico.Us
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @devlicious

Casey Charlton - Insane World

Hang the code, and hang the rules. They're more like guidelines anyway


Windsor Container Registration of Generic Component via C# Code

Update: Re-published from old blog 

I've done it before, but my mind went totally blank yesterday ... due to some typically quick responses from the Castle Users Google Group ... here is the code to do it for future generations to avoid my same silly mistakes ...

 1: WindsorContainer container = new WindsorContainer();
 2: Type eventBrokerServiceType = typeof (IEventBroker<>);
 3: Type brokerType = typeof (EventBroker<>);
 4: container.AddComponent("key", eventBrokerServiceType, brokerType);
 5: IEventBroker<EventArgs> eventBroker = 
 6:  container.Resolve<IEventBroker<EventArgs>>();
 7: Assert.IsNotNull(eventBroker);


About Casey Charlton

A somewhat passionate and opinionated developer, with occassional sparks of wisdom, and occasional useful information. Check out Devlicio.us!

Our Sponsors

Red-Gate!