/// <summary>
        /// Evaluates the policy and set the violations in the task list (error window of Visual Studio).
        /// </summary>
        /// <returns>The policy failures, if any, that occurred.</returns>
        public override PolicyFailure[] Evaluate()
        {
            PolicyFailure[] failures = null;

            using (EvaluationProcess process = new EvaluationProcess())
            {
                // Analyse if there are any violations
                process.Initialize(new EvaluationContext(this, this.Settings, this.PendingCheckin));
                failures = process.Analyze();

                if (taskProvider != null)
                {
                    // Set the settings into the taskprovider and clear it.
                    taskProvider.Settings = this.Settings;
                    taskProvider.Clear();

                    // If there are violations, add them to the tasks list (error window)
                    if (failures != null && failures.Length > 0)
                    {
                        foreach (PolicyFailure failure in failures)
                        {
                            SourceAnalysisPolicyFailure policyFailure = (SourceAnalysisPolicyFailure)failure;

                            foreach (Violation violation in policyFailure.Violations)
                            {
                                taskProvider.AddTask(violation);
                            }
                        }
                    }
                }
            }

            return(failures);
        }
        /// <summary>
        /// Activates a policy failure.
        /// </summary>
        /// <param name="failure">The failure to activate.</param>
        public override void Activate(PolicyFailure failure)
        {
            SourceAnalysisPolicyFailure policyFailure = failure as SourceAnalysisPolicyFailure;

            if (policyFailure != null)
            {
                // Create dialog to show the violations
                using (DisplayViolationsDialog dialog = new DisplayViolationsDialog())
                {
                    // Set the violations in the dialog.
                    dialog.Violations = policyFailure.Violations;

                    // Show dialog
                    dialog.ShowDialog();

                    // Check if there is a selected violation
                    if (dialog.SelectedViolation != null)
                    {
                        // There is a selected violation so move to it.
                        ViolationTask.MoveToViolation(dte, dialog.SelectedViolation);
                    }
                }
            }

            base.Activate(failure);
        }
        /// <summary>
        /// Activates a policy failure.
        /// </summary>
        /// <param name="failure">The failure to activate.</param>
        public override void Activate(PolicyFailure failure)
        {
            SourceAnalysisPolicyFailure policyFailure = failure as SourceAnalysisPolicyFailure;

            if (policyFailure != null)
            {
                using (DisplayViolationsDialog dialog = new DisplayViolationsDialog())
                {
                    dialog.Violations = policyFailure.Violations;

                    dialog.ShowDialog();
                }
            }
            var f = failure as ExtendPolicyFailure;

            if (f != null)
            {
                var zz = f.Violation;
                if (this.taskProvider != null)
                {
                    this.taskProvider.GotoError(zz);
                }
            }

            base.Activate(failure);
        }
        /// <summary>
        /// Evaluates the policy.
        /// </summary>
        /// <returns>The policy failures, if any, that occurred.</returns>
        public override PolicyFailure[] Evaluate()
        {
            PolicyFailure[] failures     = null;
            var             allViolation = new List <Violation>();

            using (EvaluationProcess process = new EvaluationProcess())
            {
                process.Initialize(new EvaluationContext(this, this.Settings, this.PendingCheckin));
                failures = process.Analyze();

                if (taskProvider != null)
                {
                    taskProvider.Settings = this.Settings;
                    taskProvider.Clear();

                    if (failures != null && failures.Length > 0)
                    {
                        foreach (PolicyFailure failure in failures)
                        {
                            SourceAnalysisPolicyFailure policyFailure = (SourceAnalysisPolicyFailure)failure;

                            foreach (Violation violation in policyFailure.Violations)
                            {
                                taskProvider.AddTask(violation);
                                allViolation.Add(violation);
                            }
                        }
                    }
                }
            }

            if (allViolation.Count > 0)
            {
                return(allViolation.Select(v => new ExtendPolicyFailure(v, this)).Cast <PolicyFailure>().ToArray());
            }

            return(failures ?? new PolicyFailure[0]);
        }