コード例 #1
0
        private WindsorContainer SetupContainer()
        {
            var container = new WindsorContainer();

            container.Kernel.ComponentRegistered += Kernel_ComponentRegistered;
            container.AddFacility <TypedFactoryFacility>();
            container.Install(FromAssembly.Containing <IWork>());

            //Alternative loading:
            CommandExtentions.AddCommandsAndProcesses(container, System.Reflection.Assembly.GetAssembly(typeof(ICommand)));



            container.Register(Component.For <WindsorContainer>().Instance(container));
            container.Register(Component.For <IRoot>().ImplementedBy <Root>());
            container.Register(Component.For <ICommandManager>().ImplementedBy <CommandManager>());

            container.Register(Component.For(typeof(IRepository <,>)).ImplementedBy(Type.GetType("WCExp.Test.BaseRepository`2")));

            container.Register(Component.For(typeof(ICommand)).ImplementedBy <SimpleCommand>().Named("SimpleCommand"));

            container.Register(Component.For(typeof(ICommand <,>)).ImplementedBy(Type.GetType("WCExp.Test.GetAllCommand`2")).Named("GetAll§Command"));

            container.Register(Component.For(typeof(ICommand <,>)).ImplementedBy(Type.GetType("WCExp.Test.GetOneCommand`2")).Named("GetOnePersonCommand"));
            container.Register(Component.For(typeof(ICommand <,>)).ImplementedBy(Type.GetType("WCExp.Test.GetOneCommand`2")).Named("GetOneCatCommand"));

            //Registering the default command with typeof
            container.Register(Component.For(typeof(ICommand <,>)).ImplementedBy(typeof(DoNothingCommand <,>)));

            //Registering with Type.GetType
            //container.Register(Component.For(typeof(ICommand<,>)).ImplementedBy(typeof(WindsorCastleExperiments.Implementations.DoNothingCommand<,>)).Named("DoNothingCommand"));

            var type = Type.GetType("WindsorCastleExperiments.Implementations.GetAllCommand`2, WindsorCastleExperiments");

            container.Register(Component.For(typeof(ICommand <,>)).ImplementedBy(type).Named("GetAllCommandOriginal"));

            // tell Windsor that it should generate factory for me
            container.Register(Component.For <ICommand2Factory>()
                               .AsFactory(new Command2Factory()));



            return(container);
        }
コード例 #2
0
 public StrikeModule(StrikeService strikesHandler, GuildService guildService, CommandExtentions commandExtentions)
 {
     _strikesHandler    = strikesHandler;
     _guildHandler      = guildService;
     _commandExtentions = commandExtentions;
 }
コード例 #3
0
 public ReplyModule(CommandService commands, GuildService guildHandler, CommandExtentions commandExtentions)
 {
     _commands          = commands;
     _guildService      = guildHandler;
     _commandExtentions = commandExtentions;
 }