Attribute Types

When you define a new type in Design Studio you select an attribute type for each attribute. Some of these attributes can contain text, like Short text, Long Text, Password, HTML, XML, and when used inside a robot there may be requirements to the text stored in these attributes. If you store text in a XML attribute, the text must be a valid XML document. This validation occurs when the type is used inside a robot, but since the API doesn't know anything about the type it doesn't validate attribute values in the same manner. As a result the API only has 8 attribute types versus the 19 available in Design Studio This table shows the mapping between the API and Design Studio attribute types.

API Attribute Type

Design Studio Attribute Type

Text

Short Text, Long Text, Password, HTML, XML, Properties, Language, Country, Currency, Refind Key

Integer

Integer

Boolean

Boolean

Number

Number

Character

Character

Date

Date

Session

Session

Binary

Binary, Image, PDF

API to Design Studio mapping


The API attribute types are then mapped to .NET in the following way.

Attribute Type

.NET Class

Text

System.String (string)

Integer

System.Int64

Boolean

System.Boolean (bool)

Number

System.Double (double)

Character

System.Char (char)

Date

System.DateTime

Session

Com.Kapowtech.Robosuite.Api.Construct.Session

Binary

Com.Kapowtech.Robosuite.Api.Construct.Binary

.NET types for attributes


The RqlObjectBuilder's setAttribute method is overloaded so you don't need to specify the attribute type explicitly when configuring an attribute through the API, as long as the right .NET class is used as argument. Here is an example that shows how to set the attributes for an object with all possible (Design Studio) attribute types.

RqlObjectBuilder inputBuilder = request.CreateInputVariable("AllTypes");
inputBuilder.SetAttributeEntry("anInt", 42L);
inputBuilder.SetAttributeEntry("aNumber", 12.34d);
inputBuilder.SetAttributeEntry("aBoolean", true);
inputBuilder.SetAttributeEntry("aCharacter", 'c');
inputBuilder.SetAttributeEntry("aShortText", "some text");
inputBuilder.SetAttributeEntry("aLongText", "a longer text");
inputBuilder.SetAttributeEntry("aPassword", "secret");
inputBuilder.SetAttributeEntry("aHTML", "<html>bla</html>");
inputBuilder.SetAttributeEntry("anXML", "<tag>text</tag>");
inputBuilder.SetAttributeEntry("aDate", DateTime.Now);
inputBuilder.SetAttributeEntry("aBinary", (Binary) null);
inputBuilder.SetAttributeEntry("aPDF", (Binary)null);
inputBuilder.SetAttributeEntry("anImage", (Binary)null);
inputBuilder.SetAttributeEntry("aProperties", "name=value\nname2=value2");
inputBuilder.SetAttributeEntry("aSession", (Session)null);
inputBuilder.SetAttributeEntry("aCurrency", "USD");
inputBuilder.SetAttributeEntry("aCountry", "US");
inputBuilder.SetAttributeEntry("aLanguage", "en");
inputBuilder.SetAttributeEntry("aRefindKey", "Never use this as input");

Recommended usage of setAttribute


Notice that in the above example we have to cast null values, because the C# compiler can't otherwise determine which of the overloaded version of SetAttributeEntry method we want to call. However since since unconfigured attributes will automatically be null, you never need to set null explicitly.

It is possible to specify the Attribute and AttributeType explicitly when creating input using the API. This is approach is not recommended, but may be needed in rare cases, and would look like this.

RqlObjectBuilder inputBuilder = request.CreateInputVariable("alltypes");
inputBuilder.SetAttributeEntry(new AttributeEntry("anInt", "42", AttributeEntryType.Integer));
inputBuilder.SetAttributeEntry(new AttributeEntry("aNumber", "12.34", AttributeEntryType.Number));
inputBuilder.SetAttributeEntry(new AttributeEntry("aBoolean", "true", AttributeEntryType.Boolean));
inputBuilder.SetAttributeEntry(new AttributeEntry("aCharacter", "c", AttributeEntryType.Character));
inputBuilder.SetAttributeEntry(new AttributeEntry("aShortText", "some text", AttributeEntryType.Text));
inputBuilder.SetAttributeEntry(new AttributeEntry("aLongText", "a longer text", AttributeEntryType.Text));
inputBuilder.SetAttributeEntry(new AttributeEntry("aPassword", "secret", AttributeEntryType.Text));
inputBuilder.SetAttributeEntry(new AttributeEntry("aHTML", "<html>bla</html>", AttributeEntryType.Text));
inputBuilder.SetAttributeEntry(new AttributeEntry("anXML", "<tag>text</tag>", AttributeEntryType.Text));
inputBuilder.SetAttributeEntry(new AttributeEntry("aDate", "2012-01-15 23:59:59.123", AttributeEntryType.Date));

inputBuilder.SetAttributeEntry(new AttributeEntry("aBinary", null, AttributeEntryType.Binary));
inputBuilder.SetAttributeEntry(new AttributeEntry("aPDF", null, AttributeEntryType.Binary));
inputBuilder.SetAttributeEntry(new AttributeEntry("anImage", null, AttributeEntryType.Binary));
inputBuilder.SetAttributeEntry(new AttributeEntry("aProperties", "name=value\nname2=value2", AttributeEntryType.Text));
inputBuilder.SetAttributeEntry(new AttributeEntry("aCurrency", "USD", AttributeEntryType.Text));
inputBuilder.SetAttributeEntry(new AttributeEntry("aCountry", "US", AttributeEntryType.Text));
inputBuilder.SetAttributeEntry(new AttributeEntry("aLanguage", "en", AttributeEntryType.Text));
inputBuilder.SetAttributeEntry(new AttributeEntry("aRefindKey", "Never use this as input", AttributeEntryType.Text));

Not recommended usage of setAttribute


As we can see all attribute values must be provided in the form of strings. The string values are then converted to the appropriate .NET objects based on the AttributeEntryType provided. This is only useful if you build other generic APIs on top of the Kapow Katalyst .NET API.