在dotnet模板中替换类型和变量

发布于 2025-02-12 01:02:23 字数 686 浏览 1 评论 0原文

假设我在模板中有一个文件,

private readonly IMyEntityRepository _myEntityRepository;

然后我有一个配置

"symbols": {
     "entity": {
        "type": "parameter",
        "datatype": "string",
        "replaces": "MyEntity",
        "fileRename": "MyEntity",
        "defaultValue": "MyEntity"
     }
  }

,然后运行命令,就像

dotnet new service-template -n RuleService --entity Rule

我最终得到的

private readonly IRuleRepository _myEntityRepository; 

那样,只想

private readonly IRuleRepository _ruleRepository; 

使用一个参数才能实现吗?

Lets say I have a file with a peace of code below in my template

private readonly IMyEntityRepository _myEntityRepository;

Then I have a configuration

"symbols": {
     "entity": {
        "type": "parameter",
        "datatype": "string",
        "replaces": "MyEntity",
        "fileRename": "MyEntity",
        "defaultValue": "MyEntity"
     }
  }

and run the command like

dotnet new service-template -n RuleService --entity Rule

In the end I get

private readonly IRuleRepository _myEntityRepository; 

but want to have

private readonly IRuleRepository _ruleRepository; 

Is that possible to achieve using just a single parameter?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文