ToTokenSelector() 공개 정적인 메소드

public static ToTokenSelector ( ITextTransformer parser, string selector ) : TokenSelector
parser ITextTransformer
selector string
리턴 TokenSelector
예제 #1
0
        protected virtual void HandleSelectorTokens(List <Token> selectorTokens)
        {
            StringBuilder sb = new StringBuilder(this.newText);

            selectorTokens.Sort(delegate(Token t1, Token t2)
            {
                return(t1.Selector == t2.Selector ? t2.Index.CompareTo(t1.Index) : string.Compare(t1.Selector, t2.Selector));
            });

            foreach (Token token in selectorTokens)
            {
                string        strSelector = token.Selector;
                TokenSelector selector    = TokenSelector.ToTokenSelector(this, strSelector);
                selector.Place(sb, token);
            }

            this.newText = sb.ToString();
        }
예제 #2
0
        public virtual string ApplyTemplate(TemplateTag tpl)
        {
            string output;

            if (this.Selector != null && this.Selector.Length > 0)
            {
                TokenSelector selector = TokenSelector.ToTokenSelector(this.Transformer, this.Selector);
                List <string> list     = selector.Matches(this.Transformer.Text, this);

                StringBuilder sb = new StringBuilder();
                foreach (string match in list)
                {
                    if (match != null && match.Length > 0)
                    {
                        sb.Append(tpl.Apply(match));
                    }
                }
                return(sb.ToString());
            }

            output = this.ManagedTokensToString();
            return(tpl.Apply(output != null && output.Length > 0 ? output : this.Value));
        }