Esempio n. 1
0
        private static IWindsorContainer RegisterDependency()
        {
            var container = new WindsorContainer();

            container.RegisterAttibuteRegistration(typeof(ClientFactory).GetTypeInfo().Assembly);

            container.Register(
                Component.For <IDictionary <Type, IRecieveHandler> >().UsingFactoryMethod(
                    kernel =>
            {
                var handlerMap = new Dictionary <Type, IRecieveHandler>();

                var allHandlers = kernel.ResolveAll <IRecieveHandler>();
                foreach (var handler in allHandlers.ToArray())
                {
                    foreach (var handleCode in handler.HandleCodes)
                    {
                        handlerMap[handleCode] = handler;
                    }
                }

                return(handlerMap);
            }));

            return(container);
        }