Codepages
Ianus implements a pluggable resource mechanism. Resources are global data items to be used by user plugins.
Resources can be of the following types:
- string
- list
- dictionary
Definition
Resources can be defined in the Ianus configuration, in the resources
element as well as in a job with the task resource
. Both configuration elements and resource
task share the same syntax.
The element resource
defines a resource. A resource has the following attribute:
Attribute | Type | Purpose | Default |
---|---|---|---|
name | string | Name of the resource | |
type | string | Type of the resource (list, dictionary, string) | string |
overwrite | bool | If set to true , the definition overwrites pre-existimg ones |
false |
The element item
defines a resource item.
Usage
Resources can be accessed using Environment.Resources
dictionary.
Examples
Resource definition in configuration
<resources>
<resource name="Dict01" type="dictionary">
<item key="01">Elem 01</item>
<item key="02">Elem 02</item>
</resource>
<resource name="ListA" type="list">
<item>String 1</item>
<item>String 2</item>
<item>String 3</item>
</resource>
<resource name="Stringazza" type="string">I am a string</resource>
<include>%IANUS_HOME%\Test\Config\IDCARD_RULES.xml</include>
</resources>
Resource definition in a job
<job>
<resource name="Dict02" type="dictionary" overwrite="false">
<item key="A">Elem A</item>
<item key="B">Elem B</item>
</resource>
</job>
### Accessing the resource
```cs
public void Initialize(HPE.Ianus.Environment e, Task t, string name, Codepage cp)
{
Patterns = (List<string>)Env.Resources["IDCARD_VALID_PATTERNS"];
Rules = (Dictionary<string, string>)Env.Resources["IDCARD_INVALID_RULES"];
}