StringTemplate.NET实例4

时间:2009-11-07 阅读: 佚名
string templates = "group simple; vardef(type,name) ::= \"<name>的属性是<type>;\" 后面还有好多字符串,我就不写这么多吧\""; StringTemplateGroup group = new StringTemplateGroup(new StringReader(templates)); StringTemplate st = group.GetInstanceOf("vardef");

            string templates = "group simple; vardef(type,name) ::= \"<name>的属性是<type>;\" 后面还有好多字符串,我就不写这么多吧\"";
            StringTemplateGroup group = new StringTemplateGroup(new StringReader(templates));
            StringTemplate st = group.GetInstanceOf("vardef");
            st.SetAttribute("type", "int");
            st.SetAttribute("name", "foo");

结果是:foo的属性是int;

[责任编辑:jumbot]

[发表评论] [收藏本页]