2

I'm referencing c# resource strings from my template (which uses $ as delimiters). I'm doing so by passing in as one of the arguments to the template the object "strings", which is a c# ResourceManager. The formatString is expected to be the name of the resource desired. This allows me to put in my template for example:

<Name>$strings;format="ItemName"$</Name>

The only issue with this solution is, there are times I want something from my object tree to help build the name of the resource string to look up. For example, a generic lookup for a localized value for an enum could be provided with:

<Type>$strings;format="ItemType$myItem.Type$"$</Type>

However - when I attempt to call the renderer this way, if I use the above syntax, the myItem.Type is not resolved into its value, and instead passed directly as part of the string, so I get the value "ItemType$myItem.Type$" rather than say, "ItemTypeBicycle".

If I don't place quotes around it however, such as:

<Type>$strings;format=ItemType$myItem.Type$$</Type>

I get a compile-time error that this "doesn't look like an expresson"

Is there another syntax I'm missing, or are you not able to resolve something that is then passed as a string like this?

AliceW
  • 41
  • 2
  • 1
    I've found a solution myself - leaving this here in case it helps someone else. The proper syntax is to escape with a { ...}, indicating an anonymous template. The output being string is assumed, giving format the required type. $strings;format={ItemType$myItem.Type$}$ – AliceW Mar 14 '16 at 19:31

0 Answers0