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

GetParameterAsInt() public method

Similar to GetParameter, but converts the type for you (if possible, throws if not).
public GetParameterAsInt ( string component, string parameter ) : int
component string The component or section of the config file, used to /// locate the parameter.
parameter string The name of the config parameter.
return int
        public int GetParameterAsInt(string component, string parameter)
        {
            int retVal;
            if (!int.TryParse(GetParameter(component, parameter), out retVal))
            {
                throw new LoggingException("Component " + component + ", parameter " +
                    parameter + ", value was unable to be converted to an integer.");
            }
            return retVal;
        }

Same methods

Config::GetParameterAsInt ( string component, string parameter, int defaultValue ) : int
Config::GetParameterAsInt ( string component, string parameter, int defaultValue ) : int?

Usage Example

 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::GetParameterAsInt