【问题标题】:How to add conditional compilation in resx file in xml format?如何在 xml 格式的 resx 文件中添加条件编译?
【发布时间】:2012-11-10 03:08:42
【问题描述】:

NET 项目中,我需要根据某些编译符号在资源文件(它是一个 xml 文件)中添加内容。

类似于以下内容:

<xml ....>
<myNodes>

#if SOMECONDITION
<node1>
...
</node1>

#else
<node2>
...
</node2>

#endif
</myNodes>

这甚至可能吗?我知道这不符合 XML 规则。是否有类似的方法可以使用条件编译但仍遵守 XML 规则?

【问题讨论】:

    标签: visual-studio-2010 c#-4.0 embedded-resource conditional-compilation


    【解决方案1】:

    我不能 100% 确定这可以解决您的问题,但您可以尝试条件构造。 xml中没有这样的条件编译。

     <rule>
        <if>
             <condition var="''$(Configuration)'" operator="=;">Debug</condition>
                <!-- more conditions possible -->
            </conditions>
            <statements>
                <!-- put your tage here -->
                <node1> ... </node1>
            </statements>
        </if>
        <else>
            <node2>
            ...
            </node2>
        </else>
    </rule>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-01-19
      • 2020-02-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多