Example #1
0
            /// <summary>
            /// Initializes a new instance of the <see cref="ReplacePatternWrapper"/> class.
            /// </summary>
            /// <param name="pattern">The pattern.</param>
            public ReplacePatternWrapper(ReplacePattern pattern)
            {
                this.pattern = pattern;
                this.constantReplacePattern = this.pattern.Replace;

                // Process regex type:
                if (pattern.ReplaceType == ReplaceType.Regex)
                {
                    // Initialize regex object:
                    this.regex = new Regex(pattern.Find, RegexOptions.Compiled);

                    // Collect all tags:
                    if (!string.IsNullOrWhiteSpace(pattern.Replace))
                    {
                        // Collect all tags:
                        MatchCollection        matches = new Regex(@"\$\{\<(?<TagName>\w+)(?>\((?<Options>(?>(?<Paren>\()|(?<-Paren>\))|[^\(\)]+)*)\))?\>\}", RegexOptions.CultureInvariant).Matches(pattern.Replace);
                        ReplacePatternSmartTag tag;
                        foreach (Match match in matches)
                        {
                            if (AllAvailableSmartTags.Tags.TryGetValue(match.Groups["TagName"].Value, out tag))
                            {
                                if (!this.usedTags.Contains(tag))
                                {
                                    this.usedTags.Add(tag);
                                }
                            }
                        }
                    }
                }
            }
Example #2
0
            /// <summary>
            /// Initializes a new instance of the <see cref="ReplacePatternWrapper"/> class.
            /// </summary>
            /// <param name="pattern">The pattern.</param>
            public ReplacePatternWrapper(ReplacePattern pattern)
            {
                this.pattern = pattern;
                this.constantReplacePattern = this.pattern.Replace;

                // Process regex type:
                if (pattern.ReplaceType == ReplaceType.Regex)
                {
                    // Initialize regex object:
                    this.regex = new Regex(pattern.Find, RegexOptions.Compiled);

                    // Collect all tags:
                    if (!string.IsNullOrWhiteSpace(pattern.Replace))
                    {
                        // Collect all tags:
                        MatchCollection matches = new Regex(@"\$\{\<(?<TagName>\w+)(?>\((?<Options>(?>(?<Paren>\()|(?<-Paren>\))|[^\(\)]+)*)\))?\>\}", RegexOptions.CultureInvariant).Matches(pattern.Replace);
                        ReplacePatternSmartTag tag;
                        foreach (Match match in matches)
                        {
                            if (AllAvailableSmartTags.Tags.TryGetValue(match.Groups["TagName"].Value, out tag))
                            {
                                if (!this.usedTags.Contains(tag))
                                    this.usedTags.Add(tag);
                            }
                        }
                    }
                }
            }