Beispiel #1
0
        private static void mfs_FileCompleted(object sender, FileCompletedEventArgs e)
        {
            string path = basePath + "\\TestApp\\TestMessages\\Done";

            FileInfo fi = new FileInfo(e.FileName);

            fi.MoveTo(path + "\\" + fi.Name);
            Console.WriteLine("File '{0}' moved.", fi.Name);
        }
Beispiel #2
0
        private static void mfs_FileCompleted(object sender, FileCompletedEventArgs e)
        {
            var path = _basePath + "\\TestApp\\TestMessages\\Done";

            Directory.CreateDirectory(path);

            var fi = new FileInfo(e.FileName);

            fi.MoveTo(path + "\\" + fi.Name);
            Console.WriteLine("File '{0}' moved.", fi.Name);
        }
Beispiel #3
0
        /// <summary>
        /// Starts the runner
        /// </summary>
        /// <param name="configFactory">The configuration factory</param>
        /// <param name="project">The project to run against</param>
        public void Run(ICalidusRuleConfigurationFactory configFactory, ICalidusProject project)
        {
            //raise started
            if (Started != null)
            {
                Started(this, new EventArgs());
            }

            IList <RuleViolation> violations = new List <RuleViolation>();

            CalidusTokenParser     parser          = new CalidusTokenParser();
            CalidusStatementParser statementParser = new CalidusStatementParser();
            CalidusBlockParser     blockParser     = new CalidusBlockParser();
            CalidusLineParser      lineParser      = new CalidusLineParser();

            CalidusRuleProvider ruleProvider = new CalidusRuleProvider();

            IEnumerable <String> filesToCheck = project.GetSourceFilesToValidate();

            int currentFile = 0;
            int totalFiles  = filesToCheck.Count();

            foreach (String aFile in filesToCheck)
            {
                currentFile++;
                IEnumerable <TokenBase>     parsedTokens     = parser.Parse(File.ReadAllText(aFile));
                IEnumerable <StatementBase> parsedStatements = statementParser.Parse(parsedTokens);
                IEnumerable <BlockBase>     parsedBlocks     = blockParser.Parse(parsedStatements);
                IEnumerable <LineBase>      parsedLines      = lineParser.Parse(parsedTokens);

                IList <RuleViolation> currentFileViolations = new List <RuleViolation>();

                foreach (StatementRuleBase aStatementRule in ruleProvider.GetStatementRules(configFactory))
                {
                    foreach (StatementBase aStatement in parsedStatements)
                    {
                        if (aStatementRule.Validates(aStatement))
                        {
                            if (aStatementRule.IsValidFor(aStatement) == false)
                            {
                                currentFileViolations.Add(new RuleViolation(aFile, aStatementRule, aStatement));
                            }
                        }
                    }
                }

                foreach (BlockRuleBase aBlockRule in ruleProvider.GetBlockRules(configFactory))
                {
                    foreach (BlockBase aBlock in parsedBlocks)
                    {
                        if (aBlockRule.Validates(aBlock))
                        {
                            if (aBlockRule.IsValidFor(aBlock) == false)
                            {
                                currentFileViolations.Add(new RuleViolation(aFile, aBlockRule, aBlock.Statements.ElementAt(0)));
                            }
                        }
                    }
                }

                foreach (LineRuleBase aLineRule in ruleProvider.GetLineRules(configFactory))
                {
                    foreach (LineBase aLine in parsedLines)
                    {
                        if (aLineRule.Validates(aLine))
                        {
                            if (aLineRule.IsValidFor(aLine) == false)
                            {
                                currentFileViolations.Add(new RuleViolation(aFile, aLineRule, aLine.Tokens));
                            }
                        }
                    }
                }

                //raise file completed
                FileCompletedEventArgs args = new FileCompletedEventArgs(aFile, currentFile, totalFiles, currentFileViolations);
                if (FileCompleted != null)
                {
                    FileCompleted(this, args);
                }

                //add violations to whole list
                foreach (RuleViolation aViolation in currentFileViolations)
                {
                    violations.Add(aViolation);
                }
            }
            //raise completed
            if (Completed != null)
            {
                Completed(this, new RuleRunnerEventArgs(violations));
            }
        }
Beispiel #4
0
        private void _runner_FileCompleted(object source, FileCompletedEventArgs e)
        {
            int i = (int)Math.Truncate((double)e.CurrentFileNumber / (double)e.TotalFileNumbers * 100.0);

            _view.DisplayProgressPercentage(i);
        }