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
        public static void Run(CommandsCollection commands)
        {
            var application = new ConsoleApplication(commands);

            application.Run();
        }
Exemplo n.º 3
0
 public async Task Upload(string from, string to = null)
 {
     to = to ?? from;
     Console.WriteLine($"upload '{from}' -> '{to}'");
     if (File.Exists(from))
     {
         await Hosting.UploadFileAsync(new FileInfo(from), to, new ConsoleProgressProvider());
     }
     else
     {
         await Hosting.UploadDirectoryAsync(new DirectoryInfo(from), to, failures, successes, (p, e) => ConsoleApplication.Log(p, e));
     }
 }