Using and operator in XMLPreprocessDirectives

Topics: Bindings File, Settings Management and SSO
Mar 8, 2016 at 9:25 AM

I am using different number of receive locations depending on environment. For that I use:
<!-- #if GetProperty("Environment")=="DEV" -->
It works fine. But can I use an OR operator in the condition? Since I have the same locations in more than one environment I would like to write something like this:
<!-- #if GetProperty("Environment")=="DEV" || GetProperty("Environment")=="TEST" -->
I tried this and it does not work, am I using the wrong syntax or is it not possible?


Mar 9, 2016 at 5:06 AM
Edited Mar 9, 2016 at 5:08 AM
Hi Johan,

XmlPreprocess.exe is not my project, so I rely on Loren's (the author) documentation. I'm surprised that statement doesn't work. According to the docs, that expression is dynamically compiled as C# and executed. Have you tried surrounding the whole expression in parentheses after the #if? You're doing case-sensitive matches there, so that could be an issue too.

It appears that the dynamic compilation is implemented with this code ( => 2.0/src/XmlPreprocess/Util/DynamicEvaluator.cs), but it's hard to interpret what it does simply by reading it.

That probably doesn't help much, but it's all I've got!

Mar 9, 2016 at 12:32 PM
Hi Tom

The parentheses did the trick.

This code worked:
        <!-- #if (GetProperty("Environment")=="DEV" || GetProperty("Environment")=="TEST")-->
Thanks a lot