ConfigurationManager external object

Official Content
This documentation is valid for:

The ConfigurationManager external object allows you to read the application configuration at runtime.
This means that you have a way to access the configuration that is being used at runtime and has been set in environment variables or configuration files (a.k.a. web.config, client.cfg., CloudServices.config).

pick1_2018727141336_1_png pick2_201872714145_1_png

Methods

HasValue 

Returns true if the property has a value set.
The parameter filename is optional. If it is not set, a valid property is one that is set in the standard configuration files (web.config / client.cfg or CloudServices.config) or an environment variable.

Return value Boolean data type
Parameters propName:VarChar [  fileName:VarChar ]

GetValue

Returns the value set in the property.
The parameter filename is optional. If it is not set, the property must be one that is set in the standard configuration files (web.config / client.cfg or CloudServices.config) or an environment variable.

Return value VarChar
Parameters propName:VarChar [  fileName:VarChar ]

 

Notes

In both methods, the name of the property is instantiated as it is in the web.config or client.cfg. If you require a property of another file, either from the CloudServices.config file or from your own, the name of the property must be prefixed with the service type separated by a colon (:). eg: Notifications: APP_ID.

If a file is specified, the format of this file must be similar to the CloudServices.config and the way to choose the value of a property is the same as in the case of the CloudServices.config (<ServiceType>:<propName>)

Sample Configuration file:

<?xml version="1.0" encoding="utf-8"?>
<Services>
  <Service>
    <Name>MyServiceName</Name>
    <Type>MyServiceType</Type>
    <ClassName>MyServiceClass</ClassName>
    <Properties>
      <Property>
        <Name>Property1</Name>
        <Value>Value of Property 1</Value>
      </Property>
      <Property>
        <Name>Property2</Name>
        <Value>Value of Property 2</Value>
      </Property>
    </Properties>
  </Service>
</Services>

To get the value of Property1, write the following:

&FileName = !"MyConfigFile.config"
&propName = !"MyServiceType:Property1"
if ConfigurationManager.HasValue(&propName, &FileName)
   msg(ConfigurationManager.GetValue(&propName, &FileName))
else
   msg("Property has not been set")
endif

Availability

Configuration Manager is available as of GeneXus 15 upgrade 12.

See also


Was this page helpful?
What Is This?
Your feedback about this content is important. Let us know what you think.