IEnumerable <IEsxiVirtualMachine> GetMachinesFromServer(IEnumerable <ConnectionInfo> connectionInfos)
        {
            var vms = new List <IEsxiVirtualMachine>();

            var codeRunner = new CrossHostCodeRunner();
            Func <PlainTextDataConverter, string, string, List <IEsxiVirtualMachine> > runnerFunc = (runner, textData, server) => runner.GetMachines(textData, server);

            foreach (var connInfo in connectionInfos)
            {
                // TODO: error handling
                vms.AddRange(codeRunner.Run <PlainTextDataConverter, List <IEsxiVirtualMachine> >(connInfo, Commands.GetVirtualMachines, runnerFunc));
            }
            return(vms);
        }
        void UnregisterMachinesOnServer(string serverName, IGrouping <string, IEsxiVirtualMachine> machineGroup)
        {
            var codeRunner = new CrossHostCodeRunner();

            // TODO: error handling
            foreach (var virtualMachine in machineGroup)
            {
                codeRunner.Run(
                    ConnectionData.Entries
                    .First(info => 0 == string.Compare(info.Host, serverName, StringComparison.OrdinalIgnoreCase)),
                    string.Format(Commands.UnregisterVirtualMachine, virtualMachine.Id)
                    );
            }
        }