Esempio n. 1
0
        public void Handle(Exception e)
        {
            ExceptionHandlerFactory factory = ExceptionHandlerFactories.GetFactory(e);
            PublisherList           list    = factory.GetPublishers();
            ExceptionRule           rule    = factory.GetRule();

            rule.Run(e, list);
        }
 public override void Handle(ExceptionRule exceptionRule)
 {
     exceptionRule.Execute(this);
 }
 public abstract void Handle(ExceptionRule exceptionRule);
 public void Handle(Exception e, ExceptionRule exceptionRule)
 {
     exceptionRule.Execute(e);
 }
        private IRule ParseRule(bool ruleGroupIsSuffix)
        {
            Gender? gender = null;
            string[] test = null;
            IModifier[] modifiers = null;
            Tags tags = Tags.None;

            JsonParser.Token startRuleToken = m_parser.AssertNextTokenTypeAndConsume(JsonParser.TokenType.ObjectStart);
            while (!m_parser.CheckNextTokenTypeAndConsumeIfTrue(JsonParser.TokenType.ObjectEnd))
            {
                string propertyName = m_parser.GetNextPropertyName();
                switch (propertyName)
                {
                case "gender":
                    gender = ParseGender(m_parser.GetNextStringValue());
                    break;
                case "test":
                    test = ParseTestStrings();
                    break;
                case "mods":
                    modifiers = ParseModifiers();
                    break;
                case "tags":
                    tags = ParseTags();
                    break;
                }
            }
            if (gender == null)
            {
                throw new ParseException("Failed to parse rule, no gender specified");
            }
            if (test == null)
            {
                throw new ParseException("Failed to parse rule, no test strings specified");
            }
            if (modifiers == null)
            {
                throw new ParseException("Failed to parse rule, no modifiers specified");
            }

            BaseRule rule;
            if (ruleGroupIsSuffix)
            {
                rule = new SufixRule(gender.Value, tags, test, modifiers);
            }
            else
            {
                rule = new ExceptionRule(gender.Value, tags, test, modifiers);
            }
            #if STORE_SOURCE_LINE_IN_RULES
            rule.startLineIndex = startRuleToken.sourceLine;
            #endif
            return rule;
        }