本文整理汇总了C#中DotLiquid.Context.GetValueTypeTransformer方法的典型用法代码示例。如果您正苦于以下问题:C# Context.GetValueTypeTransformer方法的具体用法?C# Context.GetValueTypeTransformer怎么用?C# Context.GetValueTypeTransformer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DotLiquid.Context
的用法示例。
在下文中一共展示了Context.GetValueTypeTransformer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Render
public void Render(Context context, TextWriter result)
{
object output = RenderInternal(context);
if (output is ILiquidizable)
output = null;
if (output != null)
{
// see if this context has a ValueTypeTranformer for the type
var transformer = context.GetValueTypeTransformer(output.GetType());
if (transformer == null)
{
// if the context doesn't have a ValueTypeTranformer for the type, get the global one (if there is one)
transformer = Template.GetValueTypeTransformer(output.GetType());
}
if(transformer != null)
output = transformer(output);
string outputString;
if (output is IEnumerable)
#if NET35
outputString = string.Join(string.Empty, ((IEnumerable)output).Cast<object>().Select(o => o.ToString()).ToArray());
#else
outputString = string.Join(string.Empty, ((IEnumerable)output).Cast<object>());
#endif
else if (output is bool)
outputString = output.ToString().ToLower();
else
outputString = output.ToString();
result.Write(outputString);
}