public static object GetParameter(IDictionary <string, object> parameters, string name, bool isRequired = true)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }
            else if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            else if (name.Length == 0)
            {
                throw CloudExtensions.CreateArgumentEmptyException("name");
            }

            object value = null;

            if (!parameters.TryGetValue(name, out value) && isRequired)
            {
                throw new InvalidOperationException(
                          string.Format(
                              CultureInfo.InvariantCulture,
                              Properties.Resources.ConfigurationHelper_GetParameter_NotFound,
                              name));
            }
            return(value);
        }
        public static string LookupSetting(IEnumerable <Func <string, string> > configurationSources, string name)
        {
            if (configurationSources == null)
            {
                throw new ArgumentNullException("configurationSources");
            }
            else if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            else if (name.Length == 0)
            {
                throw CloudExtensions.CreateArgumentEmptyException("name");
            }

            foreach (Func <string, string> getSettingFromSource in configurationSources)
            {
                string setting = getSettingFromSource(name);
                if (setting != null)
                {
                    return(setting);
                }
            }

            return(null);
        }
        public static Exception CreateCouldNotConvertException <T>(string name, object value)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            else if (name.Length == 0)
            {
                throw CloudExtensions.CreateArgumentEmptyException("name");
            }

            string message =
                string.Format(
                    CultureInfo.InvariantCulture,
                    "Failed to convert parameter {0} value '{1}' to type {2}.",
                    name,
                    value == null ? "(null)" : value.ToString(),
                    typeof(T).FullName);

            return(new FormatException(message));
        }