コード例 #1
0
        public void Apply(WordRange range, object source)
        {
            foreach (IReplacement replacement in Replacements)
            {
                replacement.Apply(range, source);
            }
            foreach (KeyValuePair <string, ReplacementsTree> entry in _subRanges)
            {
                string           tagName          = entry.Key;
                WordRange        nextEntry        = GetNextEntry(range, tagName);
                int              index            = 0;
                ReplacementsTree replacementsTree = entry.Value;
                IList <object>   items            = replacementsTree.GetItems(source);
                while (nextEntry != null)
                {
                    if (items.Count == 0)
                    {
                        nextEntry.Replace(tagName, string.Empty);
                    }
                    else
                    {
                        if (index < items.Count)
                        {
                            if (index < items.Count - 1)
                            {
                                nextEntry.InsertAfter(nextEntry);
                            }
                            object item = items[index];
                            replacementsTree.Apply(nextEntry, item);

                            AddBookmark(item, nextEntry);
                            index++;

                            if (index == items.Count)
                            {
                                index = 0;
                            }
                        }

                        WordRange expandedRange = nextEntry.GetExpandedRange(0, 1);
                        string    expandedText  = expandedRange.Text;
                        if (!(expandedText.Length > nextEntry.Text.Length && expandedText[expandedText.Length - 1] == '\r'))
                        {
                            expandedRange = nextEntry;
                        }
                        string[] tags = tagName.Split('*');
                        for (int i = 0; i < tags.Length; i++)
                        {
                            DeleteTag(expandedRange, tags[i]);
                        }
                    }
                    nextEntry = GetNextEntry(range, tagName);
                }
            }
        }
コード例 #2
0
 public PriceListGenerator(ReplacementsTree replacements)
 {
     _replacements = replacements;
 }
コード例 #3
0
 public void Add(string pattern, ReplacementsTree subTree)
 {
     _subRanges.Add(pattern, subTree);
 }
コード例 #4
0
 public PriceListGenerator(ReplacementsTree replacements)
 {
     _replacements = replacements;
 }
コード例 #5
0
 public void Add(string pattern, ReplacementsTree subTree)
 {
     _subRanges.Add(pattern, subTree);
 }