【问题标题】:What is the requires/provides design pattern used by the T4 RequiresProvidesDirectiveProcessor class?T4 RequiresProvidesDirectiveProcessor 类使用的要求/提供设计模式是什么?
【发布时间】:2010-12-18 22:32:18
【问题描述】:

Microsoft.VisualStudio.TextTemplating 命名空间中 RequiresProvidesDirectiveProcessor 类的 MSDN 库文档引用了一种称为“requires/provides”的设计模式。这是什么设计模式?

"指令处理器的抽象基类,定义和 实现了一种设计模式,称为 需要/提供。" - from MSDN Library

【问题讨论】:

    标签: .net visual-studio design-patterns code-generation t4


    【解决方案1】:

    实现此模式的自定义指令如下所示:

    <#@ Custom processor="CustomDirectiveProcessor" 
        requires="name=value;name=value" 
        provides="name=value;name=value"  #>
    

    它允许您在两个标准中打包多个参数 - 要求和提供。此模式用于由 DSL 工具包生成的指令处理器。

    就个人而言,我还没有发现它特别有用。在构建自定义指令处理器时,我认为将每个参数分开会更清楚。付出的努力是一样的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-25
      相关资源
      最近更新 更多