/// <summary> /// Appends the parameters to the base URL. The base URL is allowed to have parameters defined already. /// Note: It is assumed the base URL already has been properly sanitized for use. Each parameter is sanitized. /// </summary> /// <param name="baseUrl">The base URL for which the parameters are appended.</param> /// <param name="parameters">The parameters to be appended.</param> /// <returns>The complete URL with parameters appended.</returns> public static string BuildUrlQuery(string baseUrl, IDictionary parameters) { baseUrl.ThrowIfNullOrWhitespace(nameof(baseUrl)); parameters.ThrowIfNull(nameof(parameters)); string result = baseUrl; foreach (DictionaryEntry it in parameters) { if ((it.Key == null) || (it.Value == null)) { continue; } string key = SerializationUtilities.PostProcessValue <string>(it.Key); string value = SerializationUtilities.PostProcessValue <string>(it.Value); if (!string.IsNullOrEmpty(key) && !string.IsNullOrEmpty(value)) { result = AppendUrlParam(result, key, value); } } return(result); }
/// <summary> /// Attempts to process the value to one of a type that is compatible with the collection's underlying element type, if any. /// </summary> /// <param name="value">The value to process to a compatible value.</param> /// <returns>A processed value that is compatible with the underlying type of the collection.</returns> public object PostProcessValue(object value) { return(!PassesElementTypeRestriction(value) ? SerializationUtilities.PostProcessValue(value, elementType) : value); }
public object PostProcessKey(object key) { return(!PassesKeyTypeRestriction(key) ? SerializationUtilities.PostProcessValue(key, keyType) : key); }