当前位置: 首页>>代码示例>>C#>>正文


C# TemplateGroup.RegisterRenderer方法代码示例

本文整理汇总了C#中Antlr4.StringTemplate.TemplateGroup.RegisterRenderer方法的典型用法代码示例。如果您正苦于以下问题:C# TemplateGroup.RegisterRenderer方法的具体用法?C# TemplateGroup.RegisterRenderer怎么用?C# TemplateGroup.RegisterRenderer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Antlr4.StringTemplate.TemplateGroup的用法示例。


在下文中一共展示了TemplateGroup.RegisterRenderer方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ToListString

 public static string ToListString(this IList list)
 {
     TemplateGroup group = new TemplateGroup();
     group.DefineTemplate("listTemplate", "[<list:{x|<x>}; separator=\", \">]", new string[] { "list" });
     group.RegisterRenderer(typeof(IList), new CollectionRenderer());
     Template st = group.GetInstanceOf("listTemplate");
     st.Add("list", list);
     return st.Render();
 }
开发者ID:mahanteshck,项目名称:antlrcs,代码行数:9,代码来源:ListExtensions.cs

示例2: ReplacePropertyTokensInGroups

        public static string ReplacePropertyTokensInGroups(IEnumerable collection, string groupTemplate)
        {
            StringBuilder resultBuilder = new StringBuilder();

            foreach (var listItem in collection)
            {
                //We need new template for every collection item so that sub collection items like registrants are cleaned up
                TemplateGroup eventGroup = new TemplateGroup(TextTemplateUtils.DefaultTokenStartDelimiter, TextTemplateUtils.DefaultTokenEndDelimiter);
                eventGroup.RegisterRenderer(typeof(string), new StringRenderer());
                Template eventTemplate = new Template(eventGroup, groupTemplate);

                AddPropertiesToTemplate(listItem, eventTemplate);
                resultBuilder.Append(eventTemplate.Render(CultureInfo.InvariantCulture));
            }

            return resultBuilder.ToString();
        }
开发者ID:rickeygalloway,项目名称:Test,代码行数:17,代码来源:TextTemplateUtils.cs

示例3: GetTemplateGroup

        protected TemplateGroup GetTemplateGroup(List<string> templateNames)
        {
            if (tg == null)
            {
                // combile the header and all .st files and load everything into a TemplateGroup
                tg = new TemplateGroup();
                foreach (var templateName in templateNames)
                {
                    tg.ImportTemplates(GetTemplateGroupFromResource(templateName));
                }
                foreach (var type in attributeRenderers.Keys)
                {
                    var renderer = attributeRenderers[type];
                    tg.RegisterRenderer(type, renderer);
                }
            }

            return tg;
        }
开发者ID:ppdai,项目名称:TripSerializer.Net,代码行数:19,代码来源:TemplateLoader.cs

示例4: TestRendererWithFormatAndSeparatorAndNull

 public void TestRendererWithFormatAndSeparatorAndNull()
 {
     string template =
             "The names: <names; separator=\" and \", null=\"n/a\", format=\"upper\">";
     TemplateGroup group = new TemplateGroup();
     group.RegisterRenderer(typeof(string), new StringRenderer());
     Template st = new Template(group, template);
     List<string> names = new List<string>();
     names.Add("ter");
     names.Add(null);
     names.Add("sriram");
     st.Add("names", names);
     string expecting = "The names: TER and N/A and SRIRAM";
     string result = st.Render();
     Assert.AreEqual(expecting, result);
 }
开发者ID:antlr,项目名称:antlrcs,代码行数:16,代码来源:TestRenderers.cs

示例5: TestRendererWithFormatAndSeparator

 public void TestRendererWithFormatAndSeparator()
 {
     string template =
             "The names: <names; separator=\" and \", format=\"upper\">";
     TemplateGroup group = new TemplateGroup();
     group.RegisterRenderer(typeof(string), new StringRenderer());
     Template st = new Template(group, template);
     st.Add("names", "ter");
     st.Add("names", "tom");
     st.Add("names", "sriram");
     string expecting = "The names: TER and TOM and SRIRAM";
     string result = st.Render();
     Assert.AreEqual(expecting, result);
 }
开发者ID:antlr,项目名称:antlrcs,代码行数:14,代码来源:TestRenderers.cs

示例6: GetListRendererTemplateGroup

        private static TemplateGroup GetListRendererTemplateGroup()
        {
            if (_listRendererTemplateGroup == null)
            {
                _listRendererTemplateGroup = new TemplateGroupString("AttributeRendererTemplates", Properties.Resources.AttributeRendererTemplates);
                _listRendererTemplateGroup.RegisterRenderer(typeof(IEnumerable), new CollectionRenderer());
                _listRendererTemplateGroup.RegisterTypeProxyFactory(typeof(IDictionary), new DictionaryTypeProxyFactory());
                _listRendererTemplateGroup.RegisterTypeProxyFactory(typeof(Misc.Aggregate), new AggregateProxyFactory());
                _listRendererTemplateGroup.RegisterTypeProxyFactory(typeof(Template), new TemplateProxyFactory(_listRendererTemplateGroup));
            }

            return _listRendererTemplateGroup;
        }
开发者ID:mahanteshck,项目名称:antlrcs,代码行数:13,代码来源:ListExtensions.cs


注:本文中的Antlr4.StringTemplate.TemplateGroup.RegisterRenderer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。