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

GetParametersAsDictionary() public method

Gets you a Dictionary of all the parameters for the component.
public GetParametersAsDictionary ( string component ) : string>.Dictionary
component string The component or section of the config file, used to /// locate the parameter.
return string>.Dictionary
        public Dictionary<string, string> GetParametersAsDictionary(string component)
        {
            if (component == null)
            {
                throw new ArgumentNullException("component", "Component cannot be null.");
            }
            try
            {
                // Convert to upper for case insensitivity.
                return new Dictionary<string, string>(_paramsByComponent[component],
                    new CaseInsensitiveStringComparer());
            }
            catch (Exception ex)
            {
                ReThrowException("Error while getting params as Dictionary.",
                    new object[] { ConfigFile, component }, ex);
                // that throws, but the compiler wants a return statement.
                return null;
            }
        }

Usage Example

 /// <summary>
 /// Get the config for the fields to be replaced.
 /// </summary>
 /// <param name="config">The config to use.</param>
 /// <param name="component">The component name that defines the replacements.</param>
 public AddressPartDefaulter(Config config, string component)
 {
     _configParams = config.GetParametersAsDictionary(component);
 }