Example #1
0
        /// <summary>
        /// The execute.
        /// </summary>
        /// <param name="committer">
        /// The committer.
        /// </param>
        public void Execute(Action <DaemonStageResult> committer)
        {
            StyleCopTrace.In();

            // inverse the performance value - to ensure that "more resources" actually evaluates to a lower number
            // whereas "less resources" actually evaluates to a higher number. If Performance is set to max, then execute as normal.
            if ((firstRunFlag || StyleCopOptions.Instance.ParsingPerformance == StyleCopStageProcess.MaxPerformanceValue) ||
                (performanceStopWatch.Elapsed > new TimeSpan(0, 0, 0, StyleCopStageProcess.MaxPerformanceValue - StyleCopOptions.Instance.ParsingPerformance)))
            {
                if (this.daemonProcess.InterruptFlag)
                {
                    return;
                }

                if (!this.FileIsValid())
                {
                    return;
                }

                if (styleCopRunner == null)
                {
                    styleCopRunner = new StyleCopRunnerInt();
                }

                styleCopRunner.Execute(this.daemonProcess.ProjectFile, this.daemonProcess.Document);

                List <HighlightingInfo> violations =
                    (from info in styleCopRunner.ViolationHighlights
                     let range = info.Range
                                 let highlighting = info.Highlighting
                                                    select new HighlightingInfo(range, highlighting)).ToList();

                committer(new DaemonStageResult(violations));

                ResetPerformanceStopWatch();

                firstRunFlag = false;
            }

            StyleCopTrace.Out();
        }
        /// <summary>
        /// The execute.
        /// </summary>
        /// <param name="committer">
        /// The committer.
        /// </param>
        public void Execute(Action<DaemonStageResult> committer)
        {
            StyleCopTrace.In();

            // inverse the performance value - to ensure that "more resources" actually evaluates to a lower number
            // whereas "less resources" actually evaluates to a higher number. If Performance is set to max, then execute as normal.
            if ((firstRunFlag || StyleCopOptions.Instance.ParsingPerformance == StyleCopStageProcess.MaxPerformanceValue)
                || (performanceStopWatch.Elapsed > new TimeSpan(0, 0, 0, StyleCopStageProcess.MaxPerformanceValue - StyleCopOptions.Instance.ParsingPerformance)))
            {
                if (this.daemonProcess.InterruptFlag)
                {
                    return;
                }

                if (!this.FileIsValid())
                {
                    return;
                }

                if (styleCopRunner == null)
                {
                    styleCopRunner = new StyleCopRunnerInt();
                }

                styleCopRunner.Execute(this.daemonProcess.ProjectFile, this.daemonProcess.Document);

                List<HighlightingInfo> violations =
                    (from info in styleCopRunner.ViolationHighlights
                     let range = info.Range
                     let highlighting = info.Highlighting
                     select new HighlightingInfo(range, highlighting)).ToList();

                committer(new DaemonStageResult(violations));

                ResetPerformanceStopWatch();

                firstRunFlag = false;
            }

            StyleCopTrace.Out();
        }