Exemplo n.º 1
0
        static void Main(string[] args)
        {
            var hostings = new DirectoryInfo(Environment.CurrentDirectory).GetSubDirectory("hostings");

            var kernel = new StandardKernel();

            kernel.Bind(scaner =>
            {
                scaner
                .FromAssembliesInPath(hostings.FullName)
                .Select(t => typeof(IHostingManager).IsAssignableFrom(t))
                .BindAllInterfaces();
            });
            kernel.Bind(scaner =>
            {
                scaner
                .FromAssembliesInPath(hostings.FullName)
                .Select(t => typeof(IMultiHostingManager).IsAssignableFrom(t))
                .BindAllInterfaces();
            });

            kernel.Bind <ServicesCollection>().ToSelf().InSingletonScope();
            kernel.Bind <TopologyConfigurator>().ToSelf().InSingletonScope();
            kernel.Bind <IHostingProvider>().ToMethod(c => c.Kernel.Get <TopologyConfigurator>()).InSingletonScope();
            kernel.Bind <HostingTreeBuilder>().ToSelf().InSingletonScope();
            kernel.Bind <CredentialsFormatter>().ToSelf().InSingletonScope();
            kernel.Bind <FileHostingClient>().ToSelf().InSingletonScope();

            var configurator = kernel.Get <TopologyConfigurator>();
            var client       = kernel.Get <FileHostingClient>();

            var commands = new CommandsCollection();

            commands.AddCommandsProvider(configurator);
            commands.AddCommandsProvider(client);
            ConsoleApplication.Run(commands);
        }
Exemplo n.º 2
0
 private ConsoleApplication(CommandsCollection commands)
 {
     commands.AddCommandsProvider(this);
     this.commands = commands;
 }
Exemplo n.º 3
0
        public static void Run(CommandsCollection commands)
        {
            var application = new ConsoleApplication(commands);

            application.Run();
        }