◷ Reading Time: 1 minute
Var
This command will manage a defined parameter’s value. It can access the value and manipulate it. The value can be in any type and the command is able to read and write the value or properties of a value.
- name
- Description: Name of the target variable affected by the calculation or assignment, or alternatively the nested address. This name must be defined in the declaration section of the model.
- Mandatory: No
- Type: String
- ref
- Description: Reference to the variable name
- Mandatory: Yes (either value of ref is required)
- Type: String
- value
- Description: Contains the value or formula
- Mandatory: Yes (either value of ref is required)
- Type: String
- process
- Description: Defines whether the value is direct or it needs to be computed
- Mandatory: No (Default is True)
- Type: Boolean (true/false)
- source
- Description: If an extension exists for this variable assignment, it defines the source of the value on which the computation is based. For example, an XML source would be passed to the extension to calculate an XPath.
- Mandatory: No
- Type: String (name of another variable)
- path
- Description: Enables a set value, not insider properties, on the target object by referencing the properties using a dot or an element of an array using brackets, such as [3] and [index] (index can be an integer variable defined in running context). When the variable you are referencing in name has got some inner properties and you want to target them to update, you can use this setting.
- Mandatory: No
- Type: String (referencing object property of array index)
Extension
This command defines an extension point in the variable value assignment/calculation process. It must supply two parameters – assembly and handler – and the extension type must implement an interface named IExecutionExtension.
Value
Sometimes, the value cannot be assigned with a setting attribute of value to the Var command, but it can be assigned with the Value command as an internal element.
Sample
Change an variable named ‘age’ value to ’10’
<Var name="age" value="10">
Or
Change a property ‘FirstName’ of variable named ‘person’ value to ‘Joe’
<Var name="person" path="FirstName" value='"Joe"'>
Or
<Var name="Menswear">
<Value>
<![CDATA[
This is a multi line text!
Line 1
Line 2
Line 3
]]>
</Value>
</Var>
Or
<Var name="StarTotalPrice" value="(StarQty * StarPrice) - ((StarQty * StarPrice) * StarQtyDiscount)" />
Or
In this case item must be defined in the declaration section of the model.
<Var value="item.StarTotalPrice = (StarQty * StarPrice) - ((StarQty * StarPrice) * StarQtyDiscount)" />
Or
<Var name="StatementResult" source="xmlData" value="StatementAmount" process="true">
<!--
We want to handle the assignment inside our assembly
if in this case it is an xpath value.
-->
<Extension assembly="Sample.Advert.dll" handler="Sample.XPathValue"/>
</Var>