public static bool TryGetByName <T>(this IStringLookup headers, string name, out T value) { if (headers.TryGetByName(name, out var stringValue)) { value = (T)Convert.ChangeType(stringValue, typeof(T), CultureInfo.InvariantCulture); return(true); } value = default; return(false); }
public static T GetByNameOrDefault <T>(this IStringLookup headers, string name, T defaultValue) { return(headers.TryGetByName(name, out T value) ? value : defaultValue); }
public static T GetByName <T>(this IStringLookup headers, string name) { return(headers.TryGetByName(name, out T value) ? value : throw new EntryNotFoundException($"Could not find '{name}' in lookup.", name)); }
public bool TryGetByName(string name, out string value) => _values.TryGetValue(name, out value) || _parent.TryGetByName(name, out value);