コード例 #1
0
ファイル: Program.cs プロジェクト: Premsjce/RulesEngine
        private static Tuple <bool, List <InputDataUnit> > GetViolationsTuple(string inputFilePath, Rules rules)
        {
            var violationTuple = new Tuple <bool, List <InputDataUnit> >(false, null);
            List <InputDataUnit> violatedOutputRules = new List <InputDataUnit>();

            try
            {
                foreach (var inputData in JSONService.ReadInputData(inputFilePath))
                {
                    if (!RulesService.IsValidRule(inputData, rules))
                    {
                        Console.WriteLine($"{inputData.Signal}\t :\t {inputData.ValueType}\t :\t {inputData.Value}");
                        violatedOutputRules.Add(inputData);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error in raw_data.json file. " + ex.Message);
                return(violationTuple);
            }
            return(new Tuple <bool, List <InputDataUnit> >(true, violatedOutputRules));
        }