Example #1
0
 /// <summary>
 /// 解析成参数表达式
 /// </summary>
 /// <param name="context">模版解析上下文</param>
 /// <returns>需要嵌入在模版中的形式</returns>
 public string Parse( TemplateParseContext context )
 {
     return context.CreateParameterExpression( this );
 }
Example #2
0
        /// <summary>
        /// 解析模版表达式
        /// </summary>
        /// <param name="context">模版解析上下文</param>
        /// <returns>需要嵌入在模版中的形式</returns>
        public string Parse( TemplateParseContext context )
        {
            return FormatRegexNum.Replace( Template, delegate( Match match )
              {
            int index = int.Parse( match.Groups["index"].ToString() );

            if ( index >= Parameters.Length )
              throw new IndexOutOfRangeException();

            ITemplatePartialExpression partial = Parameters[index];

            return partial.Parse( context );
              }
              );
        }