本文整理汇总了C#中StringTemplate.GetTemplateDeclaratorString方法的典型用法代码示例。如果您正苦于以下问题:C# StringTemplate.GetTemplateDeclaratorString方法的具体用法?C# StringTemplate.GetTemplateDeclaratorString怎么用?C# StringTemplate.GetTemplateDeclaratorString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringTemplate
的用法示例。
在下文中一共展示了StringTemplate.GetTemplateDeclaratorString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteTemplate
protected virtual int WriteTemplate(StringTemplate self, StringTemplate stToWrite, IStringTemplateWriter @out)
{
int n = 0;
/* failsafe: perhaps enclosing instance not set
* Or, it could be set to another context! This occurs
* when you store a template instance as an attribute of more
* than one template (like both a header file and C file when
* generating C code). It must execute within the context of
* the enclosing template.
*/
stToWrite.EnclosingInstance = self;
// if self is found up the enclosing instance chain, then infinite recursion
if (StringTemplate.LintMode && StringTemplate.IsRecursiveEnclosingInstance(stToWrite))
{
// throw exception since sometimes eval keeps going even after I ignore this write of o.
throw new InvalidOperationException("infinite recursion to " +
stToWrite.GetTemplateDeclaratorString() + " referenced in " +
stToWrite.EnclosingInstance.TemplateDeclaratorString +
"; stack trace:" + Environment.NewLine + stToWrite.GetEnclosingInstanceStackTrace());
}
else
{
// if we have a wrap string, then inform writer it might need to wrap
if (_wrapString != null)
{
n = @out.WriteWrapSeparator(_wrapString);
}
// check if formatting needs to be applied to the stToWrite
if (_formatString != null)
{
IAttributeRenderer renderer = self.GetAttributeRenderer(typeof(string));
if (renderer != null)
{
/* you pay a penalty for applying format option to a template
* because the template must be written to a temp StringWriter so it can
* be formatted before being written to the real output.
*/
StringWriter buf = new StringWriter();
IStringTemplateWriter sw = self.Group.GetStringTemplateWriter(buf);
stToWrite.Write(sw);
n = @out.Write(renderer.ToString(buf.ToString(), _formatString));
return n;
}
}
n = stToWrite.Write(@out);
}
return n;
}