Ejemplo n.º 1
0
        private static Tuple <bool, Rules> GetRulesTuple()
        {
            Rules rules     = null;
            var   ruleTuple = new Tuple <bool, Rules>(false, rules);

            var rulesFilePath = ApplicationSettingsUtility.GetRulesFilePath();

            if (string.IsNullOrEmpty(rulesFilePath))
            {
                rulesFilePath = @"Input\Rules.xml";
            }
            if (!File.Exists(rulesFilePath))
            {
                Console.WriteLine("Rules.xml is not present");
                return(ruleTuple);
            }

            try
            {
                rules = XMLService.ReadRules(rulesFilePath);
                if (!ValidatorService.ValidateInputRulesForExclusivity(rules))
                {
                    Console.WriteLine("Given input rules are either not proper or Contradicting. Please check.");
                    return(ruleTuple);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("There's come problem with Rules.xml. \n" + ex.Message);
                return(ruleTuple);
            }

            try
            {
                RulesService.CheckContradictingInputValues(rules);
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error in given rules : {ex.Message}");
                return(ruleTuple);
            }

            return(new Tuple <bool, Rules>(true, rules));
        }