Exemplo n.º 1
0
        public void Execute(RuleConfigModel config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("RuleConfig");
            }

            if (!config.IsValid())
            {
                throw new Exception("Rule config content is invalid.");
            }

            ICollectListener collectListener = this.CollectListener();

            collectListener.OnStart(config.Description, config.Url, config.Level);

            RuleParser           ruleParser    = new RuleParser(config.Url, config.Level, config.GetEncoding(), config.Rules);
            CollectContinueModel continueModel = this.IsContinue ? collectListener.OnContinue(config.Description, config.Url) : null;

            if (continueModel != null)
            {
                ruleParser.LevelProcess(continueModel.ContinueUrl, continueModel.ContinueLevel, collectListener);
                this.ContinueExecute(ruleParser, config, collectListener);
            }
            else
            {
                ruleParser.LevelProcess(collectListener);
            }

            collectListener.OnEnd(config.Description, config.Url, config.Level);
        }
Exemplo n.º 2
0
        private void ContinueExecute(RuleParser ruleParser, RuleConfigModel config, ICollectListener collectListener)
        {
            CollectContinueModel continueModel = collectListener.OnContinue(config.Description, config.Url);

            if (continueModel != null)
            {
                ruleParser.LevelProcess(continueModel.ContinueUrl, continueModel.ContinueLevel, collectListener);
                this.ContinueExecute(ruleParser, config, collectListener);
            }
        }