.NET Customisation
User Guide
.NET Customisation
:
Configuration Manager
: Use the Configuration Manager
Use the Configuration Manager
A two phased approach can be used to implement the Configuration Manager.
Settings providers are requested on start-up and register any settings that can be provided.
ConfigurationManager.RegisterSetting(“DateFormat”);
Applications receive settings by requesting them by name from the ConfigurationManager
string dateFormat = ConfigurationManager.GetSetting<string>(“DateFormat”, SystemDefault);
The Configuration Manager then asks each provider in turn, via a precedence, to provide a setting value. If the provider fails to supply a setting value, the Configuration Manager then asks the next provider. If no providers supply a value, the SystemDefault is returned.
A cache may be required for performance. Settings files could be read only when the first setting is requested (lazy loading) and all the other settings cached at that point. This approach allows a selective supply of providers and supports legacy settings.
Phase I
Start read-only.
Existing data is replicated by creating legacy providers (perhaps one for each file type and one for environment variables). These providers are simple to write.
Existing applications are modified to use the Configuration Manager (it is recommended to move settings over gradually to minimise risk of error).
Phase II
Add write capability.
New style providers are added to store settings in better places (for example, a database). Use the precedence to ensure these providers are preferred, with the legacy provider as a back-up.
New consumers are added for additional functionality:
•
Configuration UI
•
Import/Export
C# API
To get a reference to the Configuration Manager:
<SPAN>;</SPAN>
Use appropriate Get/Set methods, for example:
configurationManager.GetString(key);
PML API
PML access to the configuration values is achieved via a C# object. The following methods are defined:
string GetString(string key, string default)
string GetString(string key)
boolean GetBoolean(string key, boolean default)
boolean GetBoolean(string key)
real GetInteger(string key, real default)
real GetInteger(string key)
real GetDouble(string key, real default)
real GetDouble(string key)
string GetAsString(string key)
array GetEnumNames(string key)
array GetEnumValues(string key)
boolean SetString(key, value)
boolean SetBoolean(key, boolean value)
boolean SetInteger(key, real value)
boolean SetDouble(key, real value)
boolean SetFromString(string key, string value)
The Integer methods return a REAL value.
For Get methods with a default, the default value is returned if no value exists for that name.
The Set methods return a flag indicating if the set succeeded.
The following code creates an object:
import 'Aveva.Core.Configuration.Implementation'
using namespace 'Aveva.Core.Configuration.Implementation'
!cm = object PMLConfigurationManager()
Examples of Get methods:
q var !cm.GetString('Isometrics/ALLTYPES/Text')
q var !cm.GetInteger('Isometrics/ALLTYPES/Integer')
q var !cm.GetDouble('Isometrics/ALLTYPES/Real')
q var !cm.GetBoolean('Isometrics/ALLTYPES/Boolean')
Example of the Set method:
!cm.SetString('Isometrics/ALLTYPES/Text', 'Hello Aveva')
q var !cm.GetString('Isometrics/ALLTYPES/Text')
:
Integer input
text .listLength |Length of recently used list | callback '!this.conMan.SetInteger
(|Diagrams/GeneralOptions/SystemConfiguration/System/MRU_LIST_LENGTH|, !this.listLength.val.real())' width 10 integer
Option (Drop-down)
option .isometrics01 |Drawing Size | callback '!this.conMan.SetInteger(|Isometrics/SHEETLAYOUT/DrawingSize|, !this.isometrics01.selection(|rtext|).real())' width 24
!iso01 = !this.conMan.GetInteger(|Isometrics/SHEETLAYOUT/DrawingSize|)
!enumNames = !this.conMan.GetEnumNames(|Isometrics/SHEETLAYOUT/DrawingSize|)
!enumValues = !this.conMan.GetEnumValues(|Isometrics/SHEETLAYOUT/DrawingSize|)
!this.isometrics01.dText = !enumNames
!this.isometrics01.rText = !enumValues
!this.isometrics01.select('rtext','$!iso01')
Toggle
toggle .isometrics02 |Show Change Highlighting | callback '!this.conMan.SetBoolean(|Isometrics/CHANGEHIGHLIGHTING/HIGHLIGHTINDICATOR|, !this.isometrics02.val)'
1974 to current year.
AVEVA Solutions Limited and its subsidiaries. All rights reserved.