开发者

Is there any way to have functions in basic T4 templates?

开发者 https://www.devze.com 2022-12-19 08:50 出处:网络
By basic T4 template, I mean not using T4 Toolkit or any of the add-ins. My T4 is getting a little complicated, but I\'d like to keep in self-contained for now.Is there a way have functions in your T

By basic T4 template, I mean not using T4 Toolkit or any of the add-ins.

My T4 is getting a little complicated, but I'd like to keep in self-contained for now. Is there a way have functions in your T4 template, wi开发者_如何学Gothout referencing external assemblies?


You mean like this:

<#+
    public List<string> Dostuff()
    {
        List<string> result = new List<string>(); 

        // ...

        return result;
    }
#>

Here's a complete example: Reading a Xml File in T4 Templates

Oleg Sych's T4Toolbox is a good resource.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号