什么是围绕属性值的方括号?

时间:2013-03-22 02:46:47

标签: visual-studio xaml tfs build-process

在TFS DefaultTemplate.11.1.xaml构建过程模板中,有许多属性的整个值都用方括号[]包围,因此标记的格式为

<tagName attributeName="[attributeValue]">

其中tagNameattributeNameattributeValue是文本字符串。

我找不到此值语法的任何文档。从模板中,它似乎导致XAML处理器将文本评估为表达式。这是在某处解释的吗?

2 个答案:

答案 0 :(得分:1)

我相信XAML中的方括号确实表示值表达式。我仍然不确定这种表示是如何得到支持或强制执行的。可能性包括:

-XAML语法;我认为这是最可能的答案。

-A Converter实现某处在解析期间检测值何时开始和以方括号结束,并在处理期间评估内容;我认为这是第二个最可能的答案。

- 方括号实际上可能不是特殊字符并且作为标识符的一部分有效,值的评估是通过其他一些尚未知的机制来执行的,并且方括号仅按惯例存在,也许表示该值不是文字而是要评估的表达式。我认为这是一个不太可能的答案。

支持研究:

  

"Expressions created in the WF designer are serialized using square brackets, which is shorthand for VisualBasicValue or VisualBasicReference"

     

"Hand edit the workflow XAML file to change value of the Number property to [1+2] (the square brackets denote an expression)"

     

"Expressions are literal values or Visual Basic code bound to arguments or properties. They contain value elements (e.g. variables, constants, literals, properties) that are combined with operations to yield a new value. Expressions are written using VB.NET syntax even if the application is in a program using C#."

     

"Workflows produced by designer are saved in XAML, where expressions appear enclosed in square brackets."

上面的最后一个引用是我发现的唯一官方文档,它以任何方式提到围绕表达式的方括号作为XAML属性值,这仍然没有说明设计者是否只是随意地执行此操作而不调用任何特殊语法,或者,如果表达式必须根据官方XAML规范显示在方括号中,并且设计者必须这样做。

答案 1 :(得分:0)

这是之前在XAML中设置的属性,例如:<x:Property Name="BuildNumberFormat" Type="InArgument(x:String)" />如果在VS 2012中打开构建过程模板,则可以使用Workflow更改/自定义它们。 / p>