示例#1
0
        public override void Update(string txt)
        {
            var tmp = SpecificRule.FromFullname(txt);

            this.Schema  = tmp.Schema;
            this.Routine = tmp.Routine;
        }
示例#2
0
        public CommonReturnValue AddRule(RuleType ruleType, string txt)
        {
            BaseRule rule = null;

            switch (ruleType) // TODO: Check for duplicated rules?
            {
            case RuleType.Schema:
                rule = new SchemaRule(txt);
                break;

            case RuleType.Specific:
            {
                rule = SpecificRule.FromFullname(txt);
            }
            break;

            case RuleType.Regex:
            {
                try
                {
                    var regexTest = new Regex(txt);
                }
                catch (Exception ex)
                {
                    return(CommonReturnValue.UserError("Invalid regex pattern: " + ex.ToString()));
                }

                rule = new RegexRule(txt);
                break;
            }

            default:
                throw new Exception($"Unsupported rule type: ${ruleType}");
            }

            rule.Id = ShortId.Generate(useNumbers: true, useSpecial: true, length: 6);

            this.Rules.Add(rule);

            return(CommonReturnValue.Success());
        }