当前位置: 首页>>代码示例>>C#>>正文


C# IIntegrationResult.Clone方法代码示例

本文整理汇总了C#中IIntegrationResult.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# IIntegrationResult.Clone方法的具体用法?C# IIntegrationResult.Clone怎么用?C# IIntegrationResult.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IIntegrationResult的用法示例。


在下文中一共展示了IIntegrationResult.Clone方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Execute

        /// <summary>
        /// Runs the task, given the specified <see cref="IIntegrationResult"/>, in the specified <see cref="IProject"/>.
        /// </summary>
        /// <param name="result"></param>
        protected override bool Execute(IIntegrationResult result)
        {
            // Initialise the task
            var logger = Logger ?? new DefaultLogger();
            var numberOfTasks = Tasks.Length;
            tasksDetails = new ParallelRunningSubTaskDetails[numberOfTasks];
            result.BuildProgressInformation.SignalStartRunTask(GetStatusInformation(null));
            logger.Info("Starting parallel task with {0} sub-task(s)", numberOfTasks);

            // Initialise the arrays
            var events = new ManualResetEvent[numberOfTasks];
            var results = new IIntegrationResult[numberOfTasks];

            for (var loop = 0; loop < numberOfTasks; loop++)
            {
                events[loop] = new ManualResetEvent(false);
                results[loop] = result.Clone();
                tasksDetails[loop] = new ParallelRunningSubTaskDetails(loop, result);
            }

            // Launch each task using the ThreadPool
            var countLock = new object();
            var successCount = 0;
            var failureCount = 0;
            for (var loop = 0; loop < numberOfTasks; loop++)
            {
                ThreadPool.QueueUserWorkItem((state) =>
                {
                    var taskNumber = (int)state;
                    var taskName = string.Format(System.Globalization.CultureInfo.CurrentCulture,"{0} [{1}]", Tasks[taskNumber].GetType().Name, taskNumber);
                    try
                    {
                        Thread.CurrentThread.Name = string.Format(System.Globalization.CultureInfo.CurrentCulture,"{0} [Parallel-{1}]", result.ProjectName, taskNumber);
                        logger.Debug("Starting task '{0}'", taskName);

                        // Start the actual task
                        var task = Tasks[taskNumber];
                        var taskResult = results[taskNumber];
                        RunTask(task, taskResult, tasksDetails[taskNumber]);
                    }
                    catch (Exception error)
                    {
                        // Handle any error details
                        results[taskNumber].ExceptionResult = error;
                        results[taskNumber].Status = IntegrationStatus.Failure;
                        logger.Warning("Task '{0}' failed!", taskName);
                    }

                    // Record the results
                    lock (countLock)
                    {
                        if (results[taskNumber].Status == IntegrationStatus.Success)
                        {
                            successCount++;
                        }
                        else
                        {
                            failureCount++;
                        }
                    }

                    tasksDetails[taskNumber].Finished = true;
                    tasksDetails[taskNumber].ParentResult.BuildProgressInformation.UpdateStartupInformation(GetStatusInformation(tasksDetails[taskNumber]));

                    // Tell everyone the task is done
                    events[taskNumber].Set();

                }, loop);

            }

            // Wait for all the tasks to complete
            logger.Debug("Waiting for tasks to complete");
            WaitHandle.WaitAll(events);

            // Merge all the results
            logger.Info("Merging task results");
            foreach (var taskResult in results)
            {
                result.Merge(taskResult);
            }

            // Clean up
            this.CancelTasks();
            logger.Info("Parallel task completed: {0} successful, {1} failed", successCount, failureCount);
            return true;
        }
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:91,代码来源:ParallelTask.cs

示例2: Execute

        /// <summary>
        /// Execute the actual task functionality.
        /// </summary>
        /// <param name="result">The result to use.</param>
        /// <returns>
        /// True if the task was successful, false otherwise.
        /// </returns>
        protected override bool Execute(IIntegrationResult result)
        {
            // Initialise the task
            var logger = Logger ?? new DefaultLogger();
            var numberOfTasks = Tasks.Length;
            result.BuildProgressInformation.SignalStartRunTask(!string.IsNullOrEmpty(Description)
                ? Description
                : string.Format(System.Globalization.CultureInfo.CurrentCulture, "Running tasks in synchronisation context({0} task(s))", numberOfTasks));
            logger.Info("Starting synchronisation task with {0} sub-task(s)", numberOfTasks);
            var contextToUse = this.ContextName ?? "DefaultSynchronisationContext";

            // Make sure the context has been loaded
            lock (lockObject)
            {
                if (!contexts.ContainsKey(contextToUse))
                {
                    contexts.Add(contextToUse, new object());
                }
            }

            // Attempt to enter the synchronisation context
            if (Monitor.TryEnter(contexts[contextToUse], TimeoutPeriod * 1000))
            {
                try
                {
                    // Launch each task
                    var successCount = 0;
                    var failureCount = 0;
                    for (var loop = 0; loop < numberOfTasks; loop++)
                    {
                        var taskName = string.Format(System.Globalization.CultureInfo.CurrentCulture, "{0} [{1}]", Tasks[loop].GetType().Name, loop);
                        logger.Debug("Starting task '{0}'", taskName);
                        try
                        {
                            // Start the actual task
                            var taskResult = result.Clone();
                            var task = Tasks[loop];
                            RunTask(task, taskResult);
                            result.Merge(taskResult);
                        }
                        catch (Exception error)
                        {
                            // Handle any error details
                            result.ExceptionResult = error;
                            result.Status = IntegrationStatus.Failure;
                            logger.Warning("Task '{0}' failed!", taskName);
                        }

                        // Record the results
                        if (result.Status == IntegrationStatus.Success)
                        {
                            successCount++;
                        }
                        else
                        {
                            failureCount++;
                            if (!ContinueOnFailure) break;
                        }
                    }
                    logger.Info("Parallel task completed: {0} successful, {1} failed", successCount, failureCount);
                }
                finally
                {
                    Monitor.Exit(contexts[contextToUse]);
                }
            }
            else
            {
                // Set the result as failed
                logger.Warning("Unable to enter synchonisation context!");
                result.Status = IntegrationStatus.Failure;
            }

            // Clean up
            this.CancelTasks();
            return (result.Status == IntegrationStatus.Success);
        }
开发者ID:robrich,项目名称:CruiseControl.NET,代码行数:84,代码来源:SynchronisationTask.cs

示例3: Execute

        /// <summary>
        /// Runs the task, given the specified <see cref="IIntegrationResult"/>, in the specified <see cref="IProject"/>.
        /// </summary>
        /// <param name="result"></param>
        protected override bool Execute(IIntegrationResult result)
        {
            // Initialise the task
            var logger = Logger ?? new DefaultLogger();
            var numberOfTasks = Tasks.Length;
            result.BuildProgressInformation.SignalStartRunTask(_getStatusInformation("", null));
            logger.Info("Starting sequential task with {0} sub-task(s)", numberOfTasks);

            // Launch each task
            var successCount = 0;
            var failureCount = 0;
            for (var loop = 0; loop < numberOfTasks; loop++)
            {
                var taskName = string.Format(System.Globalization.CultureInfo.CurrentCulture,"{0} [{1}]", Tasks[loop].GetType().Name, loop);
                logger.Debug("Starting task '{0}'", taskName);
                try
                {
                    // Start the actual task
                    var taskResult = result.Clone();
                    taskResult.BuildProgressInformation.OnStartupInformationUpdatedUserObject = new _RunningSubTaskDetails(loop, result);
                    taskResult.BuildProgressInformation.OnStartupInformationUpdated = SubTaskStartupInformationUpdated;
                    var task = Tasks[loop];
                    RunTask(task, taskResult);
                    result.Merge(taskResult);
                }
                catch (Exception error)
                {
                    // Handle any error details
                    result.ExceptionResult = error;
                    result.Status = IntegrationStatus.Failure;
                    logger.Warning("Task '{0}' failed!", taskName);
                }

                // Record the results
                if (result.Status == IntegrationStatus.Success)
                {
                    successCount++;
                }
                else
                {
                    failureCount++;
                    if (!ContinueOnFailure) break;
                }
            }

            // Clean up
            this.CancelTasks();
            logger.Info("Sequential task completed: {0} successful, {1} failed", successCount, failureCount);
            return failureCount == 0;
        }
开发者ID:angolon,项目名称:CruiseControl.NET,代码行数:54,代码来源:SequentialTask.cs

示例4: Execute

            protected override bool Execute(IIntegrationResult result)
            {
                int loop = 0;
                foreach (var task in Tasks)
                {
                    var taskResult = result.Clone();
                    RunTask(task, taskResult, new RunningSubTaskDetails(loop, result));
                    result.Merge(taskResult);

                    loop++;
                }
                return true;
            }
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:13,代码来源:TaskContainerBaseTests.cs

示例5: RunTasks

        /// <summary>
        /// Runs some tasks.
        /// </summary>
        /// <param name="tasks">The tasks.</param>
        /// <param name="logger">The logger.</param>
        /// <param name="runningIfTasks">true if running the "if" tasks.</param>
        /// <param name="result">The result.</param>
        /// <returns><c>true</c> if all the tasks are successul; <c>false</c> otherwise.</returns>
        private bool RunTasks(ITask[] tasks, ILogger logger, bool runningIfTasks, IIntegrationResult result)
        {
            // Launch each task
            var successCount = 0;
            var failureCount = 0;
            for (var loop = 0; loop < tasks.Length; loop++)
            {
                var taskName = string.Format(System.Globalization.CultureInfo.CurrentCulture,"{0} [{1}]", tasks[loop].GetType().Name, loop);
                logger.Debug("Starting task '{0}'", taskName);
                try
                {
                    // Start the actual task
                    var taskResult = result.Clone();
                    var task = tasks[loop];
                    this.RunTask(task, taskResult, new RunningSubTaskDetails(loop, runningIfTasks, result));
                    result.Merge(taskResult);
                }
                catch (Exception error)
                {
                    // Handle any error details
                    result.ExceptionResult = error;
                    result.Status = IntegrationStatus.Failure;
                    logger.Warning("Task '{0}' failed!", taskName);
                }

                // Record the results
                if (result.Status == IntegrationStatus.Success)
                {
                    successCount++;
                }
                else
                {
                    failureCount++;
                    if (!ContinueOnFailure)
                        break;
                }
            }

            logger.Info("Tasks completed: {0} successful, {1} failed", successCount, failureCount);
            return failureCount == 0;
        }
开发者ID:nickdurcholz,项目名称:CruiseControl.NET,代码行数:49,代码来源:ConditionalTask.cs

示例6: AddResultMockExpectedClone

 private void AddResultMockExpectedClone(IIntegrationResult result)
 {
     Expect.Call(result.Clone()).
         Do((Func<IIntegrationResult>)(() =>
         {
             var clone = mocks.StrictMock<IIntegrationResult>();
             SetupResult.For(clone.BuildProgressInformation).Return(result.BuildProgressInformation);
             SetupResult.For(clone.Status).PropertyBehavior();
             SetupResult.For(clone.ExceptionResult).PropertyBehavior();
             clone.Status = result.Status;
             clone.Replay();
             return clone;
         }));
 }
开发者ID:nickdurcholz,项目名称:CruiseControl.NET,代码行数:14,代码来源:ConditionalTaskTests.cs

示例7: RunTaskAndMergeResult

		private static void RunTaskAndMergeResult(ITask task, IIntegrationResult result)
		{
			IIntegrationResult subResult = result.Clone();
			try
			{
				task.Run(subResult);
			}
			finally
			{
				result.Merge(subResult);
			}
		}
开发者ID:timonela,项目名称:mb-unit,代码行数:12,代码来源:VMTask.cs

示例8: Execute

        /// <summary>
        /// Runs the task, given the specified <see cref="IIntegrationResult"/>, in the specified <see cref="IProject"/>.
        /// </summary>
        /// <param name="result">The results of the current build.</param>
        /// <returns><c>true</c> if the execution is successful; <c>false</c> otherwise.</returns>
        protected override bool Execute(IIntegrationResult result)
        {
            // Initialise the publisher
            var logger = this.Logger ?? new DefaultLogger();
            result.BuildProgressInformation.SignalStartRunTask(!string.IsNullOrEmpty(Description)
                ? Description
                : "Checking conditional publishers");
            logger.Info("Checking conditional publishers");

            // Check the conditions
            var runPublishers = false;
            foreach (var condition in this.Conditions ?? new IntegrationStatus[0])
            {
                runPublishers |= condition == result.Status;
            }

            if (runPublishers)
            {
                // Run each publisher
                logger.Info("Conditions met - running publishers");
                for (var loop = 0; loop < this.Tasks.Length; loop++)
                {
                    logger.Debug("Running publisher #{0}", loop);
                    try
                    {
                        var taskResult = result.Clone();
                        var publisher = this.Tasks[loop];
                        RunTask(publisher, taskResult, new RunningSubTaskDetails(loop, result));
                        result.Merge(taskResult);
                    }
                    catch (Exception e)
                    {
                        logger.Error("Publisher threw exception: {0}", e.Message);
                    }
                }
            }
            else
            {
                logger.Info("Conditions not met - publishers not run");
            }

            // Clean up
            this.CancelTasks();
            return true;
        }
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:50,代码来源:ConditionalPublisher.cs


注:本文中的IIntegrationResult.Clone方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。