Exemple #1
0
        protected RegExpBase(RegexOptions options, object id, string regExp, bool build, object score, object factor, string prefixMatch, string suffixMatch, object color, string lookAhead, string lookBehind, string negLookAhead, string negLookBehind, string exceptions, string description, object categoryID)
        {
            _id = Convert.ToInt32(id);

            _expression = regExp;
            _options    = options;

            _categoryRecords = new Dictionary <int, int>();

            this.Description = description;

            ///////////////////////////////////////////////////////////////////////////////

            this.PrefixMatch = prefixMatch;
            this.SuffixMatch = suffixMatch;

            if (String.IsNullOrEmpty(this.PrefixMatch))
            {
                this.PrefixMatch = _defaultPrefixMatch;
            }

            if (String.IsNullOrEmpty(this.SuffixMatch))
            {
                this.SuffixMatch = _defaultSuffixMatch;
            }

            ///////////////////////////////////////////////////////////////////////////////

            if (score != null)
            {
                this.Score = Convert.ToInt32(score);
            }

            if (factor != null)
            {
                this.Factor = Convert.ToInt32(factor);
            }

            if (color != null)
            {
                var argb = Convert.ToInt32(color);

                _color = argb != 0 ? Color.FromArgb(argb) : DefaultHighlightColor;
            }

            this.Category = (int?)categoryID;

            this.LookAhead     = RegExpCriteriaCollection.FromString(RegExpCriteriaType.LookAhead, lookAhead);
            this.LookBehind    = RegExpCriteriaCollection.FromString(RegExpCriteriaType.LookBehind, lookBehind);
            this.NegLookAhead  = RegExpCriteriaCollection.FromString(RegExpCriteriaType.NegLookAhead, negLookAhead);
            this.NegLookBehind = RegExpCriteriaCollection.FromString(RegExpCriteriaType.NegLookBehind, negLookBehind);

            this.Exceptions = RegExpCriteriaCollection.FromString(RegExpCriteriaType.Exception, exceptions);

            ///////////////////////////////////////////////////////////////////////////////

            this.LookAhead.Enabled  = !this.NegLookAhead.Enabled;
            this.LookBehind.Enabled = !this.NegLookBehind.Enabled;

            NormalizeCriteria();

            ///////////////////////////////////////////////////////////////////////////////

            if (build)
            {
                Build();
            }
        }