/// <summary>The execute commands.</summary>
        public void ExecuteCommands()
        {
            foreach (Command fileCommand in
                _commands.Where(com => com.Name == "FileCommand").ToArray())
            {
                var commandPrcessor = _application.Container.Resolve<IFileCommand>(null, true);
                if (commandPrcessor == null) break;

                string file = fileCommand.Parms[0];

                commandPrcessor.ProcessFile(file);
                _factory = commandPrcessor.ProvideFactory();
            }

            foreach (ICommandLineCommand command in
                _application.Container.Resolve<ICommandLineService>().Commands)
            {
                ICommandLineCommand command1 = command;
                Command temp = _commands.FirstOrDefault(arg => arg.Name == command1.CommandName);
                if (temp == null) continue;

                command.Execute(temp.Parms.ToArray(), _application.Container);
            }

            _commands = null;
        }
 public static IShellFactory ResolveIShellFactory()
 {
     if (shellFactory == null)
     {
         shellFactory = new ShellFactory();
     }
     return shellFactory;
 }
 /// <summary>
 /// Create virtual machine factory
 /// </summary>
 /// <param name="creds"></param>
 /// <param name="selector"></param>
 /// <param name="shell"></param>
 /// <param name="logger"></param>
 public VirtualMachineFactory(ICredentialProvider creds,
                              ISubscriptionInfoSelector selector, IShellFactory shell,
                              ILogger logger) : base(creds, logger)
 {
     _shell = shell ??
              throw new ArgumentNullException(nameof(shell));
     _selector = selector ??
                 throw new ArgumentNullException(nameof(selector));
 }
Example #4
0
 /// <summary>
 /// Open shell to destination
 /// </summary>
 /// <param name="factory"></param>
 /// <param name="host"></param>
 /// <param name="credentials"></param>
 /// <returns></returns>
 public static Task <ISecureShell> OpenSecureShellAsync(this IShellFactory factory,
                                                        string host, NetworkCredential credentials) =>
 factory.OpenSecureShellAsync(host, credentials, CancellationToken.None);
Example #5
0
 /// <summary>
 /// Open shell to destination
 /// </summary>
 /// <param name="factory"></param>
 /// <param name="host"></param>
 /// <param name="userName"></param>
 /// <param name="password"></param>
 /// <returns></returns>
 public static Task <ISecureShell> OpenSecureShellAsync(this IShellFactory factory,
                                                        string host, string userName, string password) =>
 factory.OpenSecureShellAsync(host, new NetworkCredential(userName, password));
Example #6
0
 /// <summary>
 /// Open shell to destination
 /// </summary>
 /// <param name="factory"></param>
 /// <param name="host"></param>
 /// <param name="port"></param>
 /// <param name="userName"></param>
 /// <param name="password"></param>
 /// <param name="ct"></param>
 /// <returns></returns>
 public static Task <ISecureShell> OpenSecureShellAsync(this IShellFactory factory,
                                                        string host, int port, string userName, string password, CancellationToken ct) =>
 factory.OpenSecureShellAsync(host, port, new NetworkCredential(userName, password), ct);
        /// <summary>The select view facotry.</summary>
        private void SelectViewFacotry()
        {
            Contract.Requires(_application != null);

            if (_factory != null) return;

            foreach (ICommandLineCommand command in
                _application.Container.Resolve<ICommandLineService>()
                           .Commands.Where(
                               command =>
                               command.Factory != null &&
                               _commands.Any(com => com.Name == command.CommandName))
                ) _factory = command.Factory;
        }
Example #8
0
 public CommandFactory(IShellFactory shellFactory, IDockhandEnvironment environment)
 {
     _shellFactory = shellFactory;
     _environment  = environment;
 }
Example #9
0
 /// <inheritdoc />
 public IShellFactory GetShellFactory()
 {
     return(_shellFactory ?? (_shellFactory = new ShellFactory()));
 }
Example #10
0
 /// <summary>
 /// Open shell to destination
 /// </summary>
 /// <param name="factory"></param>
 /// <param name="host"></param>
 /// <param name="credentials"></param>
 /// <param name="ct"></param>
 /// <returns></returns>
 public static Task <ISecureShell> OpenSecureShellAsync(this IShellFactory factory,
                                                        string host, NetworkCredential credentials, CancellationToken ct)
 {
     return(factory.OpenSecureShellAsync(host, 22, credentials, ct));
 }
Example #11
0
 /// <summary>
 /// Returns the factory that is used to create shells.
 /// The factory is created the first time it's required.
 /// </summary>
 /// <seealso cref="IShell"/>
 /// <returns>Factory for creating shells</returns>
 public IShellFactory GetShellFactory()
 {
     return(_shellFactory ?? (_shellFactory = _uiProvider.GetShellFactory()));
 }