當前位置: 首頁>>代碼示例>>C#>>正文


C# Result.AddRange方法代碼示例

本文整理匯總了C#中System.Result.AddRange方法的典型用法代碼示例。如果您正苦於以下問題:C# Result.AddRange方法的具體用法?C# Result.AddRange怎麽用?C# Result.AddRange使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Result的用法示例。


在下文中一共展示了Result.AddRange方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: InstallUninstall

        /// <summary>
        /// Install/uninstall MSI
        /// </summary>
        /// <returns></returns>
        public Result InstallUninstall(InstanceOptions options)
        {
            ConsoleOutput.WriteLine("Running 'Remote:{0}', '{1}'", _installerConfig.Name, _installerConfig.DestinationPath);

            // remote logfiles
            string install_logfile = string.Empty;
            string uninstall_logfile = string.Empty;

            // the remote install result
            Result result = new Result(
                _installerConfig.Name,
                _installerConfig.SvnRevision);

            if (!Directory.Exists(LogPath))
            {
                ConsoleOutput.WriteLine("Creating directory '{0}'", LogPath);
                Directory.CreateDirectory(LogPath);
            }

            ConsoleOutput.WriteLine("Saving logs in '{0}'", LogPath);

            SequenceDrivers additionalSequences = new SequenceDrivers();

            ExecuteDriver executeDriver = new ExecuteDriver(this);
            executeDriver.Add(_config.Tasks);
            executeDriver.Add(_config.VirtualMachines.Tasks);
            executeDriver.Add(_vmConfig.Tasks);
            executeDriver.Add(_vmConfig.Snapshots.Tasks);
            executeDriver.Add(_snapshotConfig.Tasks);
            executeDriver.Add(_config.Installers.Tasks);
            executeDriver.Add(_installerConfig.Tasks);
            additionalSequences.Add(executeDriver);

            CopyFilesDriver copyFilesDriver = new CopyFilesDriver(this);
            copyFilesDriver.Add(_config.CopyFiles);
            copyFilesDriver.Add(_config.VirtualMachines.CopyFiles);
            copyFilesDriver.Add(_vmConfig.CopyFiles);
            copyFilesDriver.Add(_vmConfig.Snapshots.CopyFiles);
            copyFilesDriver.Add(_snapshotConfig.CopyFiles);
            copyFilesDriver.Add(_config.Installers.CopyFiles);
            copyFilesDriver.Add(_installerConfig.CopyFiles);
            additionalSequences.Add(copyFilesDriver);

            // execute and copy files before all
            result.AddRange(additionalSequences.ExecuteSequence(
                SequenceWhen.beforeall));

            DateTime start = DateTime.UtcNow;
            try
            {
                // execute the installers
                try
                {
                    VirtualMachineDeployment deploy = null;

                    if (!_simulationOnly)
                    {
                        deploy = _installerConfig.CreateDeployment(_vm);
                    }

                    // install
                    if (options.Install)
                    {
                        // execute and copy files before install
                        result.AddRange(additionalSequences.ExecuteSequence(
                            SequenceWhen.beforeinstall));

                        ConsoleOutput.WriteLine("Installing 'Remote:{0}', '{1}'",
                            _installerConfig.Name, _installerConfig.DestinationPath);

                        result.SuccessfulInstall = InstallResult.False;

                        if (!_simulationOnly)
                        {
                            deploy.Install(out install_logfile);
                        }

                        result.SuccessfulInstall = InstallResult.True;
                        result.AddRange(additionalSequences.ExecuteSequence(
                            SequenceWhen.aftersuccessfulinstall));
                    }

                    // uninstall
                    if (options.Uninstall)
                    {
                        // execute and copy files before uninstall
                        result.AddRange(additionalSequences.ExecuteSequence(
                            SequenceWhen.beforeuninstall));

                        DateTime startUnInstall = DateTime.UtcNow;
                        ConsoleOutput.WriteLine("Uninstalling 'Remote:{0}', '{1}'", _installerConfig.Name, _installerConfig.DestinationPath);

                        result.SuccessfulUnInstall = InstallResult.False;

                        if (!_simulationOnly)
                        {
//.........這裏部分代碼省略.........
開發者ID:blinds52,項目名稱:remoteinstall,代碼行數:101,代碼來源:Instance.cs


注:本文中的System.Result.AddRange方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。