Azavea.Open.Common.Config.GetParameter C# (CSharp) Method

GetParameter() public method

Returns the config parameter for the given component. Throws an exception if there is no such parameter. If you want to know if the parameter exists, call ParameterExists(...).
public GetParameter ( string component, string parameter ) : string
component string The component or section of the config file, used to /// locate the parameter.
parameter string The name of the config parameter.
return string
        public string GetParameter(string component, string parameter)
        {
            if (component == null)
            {
                throw new ArgumentNullException("component", "Component cannot be null.  Parameter was '" +
                    parameter + "'.");
            }
            if (parameter == null)
            {
                throw new ArgumentNullException("parameter", "Parameter cannot be null.  Component was '" +
                    component + "'.");
            }
            try
            {
                return _paramsByComponent[component][parameter];
            }
            catch (Exception ex)
            {
                ReThrowException("Unable to read parameter.",
                    new object[] { ConfigFile, component, parameter }, ex);
                // that throws, but the compiler wants a return statement.
                return "never gets here";
            }
        }

Same methods

Config::GetParameter ( string component, string parameter, string defaultValue ) : string

Usage Example

Ejemplo n.º 1
0
 public OdpSdeStDescriptor(Config config, string component, ConnectionInfoDecryptionDelegate decryptionDelegate)
     : base(config.GetParameter(component, "Server", null),
            config.GetParameter(component, "User", null),
            GetDecryptedConfigParameter(config, component, "Password", decryptionDelegate),
            config.GetParameterAsInt(component, "Connect_Timeout", null))
 {
 }
All Usage Examples Of Azavea.Open.Common.Config::GetParameter