/// <summary> /// Validate a Top Level Domain /// </summary> /// <returns></returns> public static bool IsValid(string ianaCode) { // ReSharper disable once ConvertIfStatementToReturnStatement if (string.IsNullOrEmpty(ianaCode)) { return(false); } ianaCode = ianaCode.Trim(); return(IanaDict.ContainsKey(ianaCode)); }
public static IanaCode FromString(string ianaCodeString) { if (string.IsNullOrEmpty(ianaCodeString)) { throw new InvalidTimeZoneCode(ianaCodeString); } ianaCodeString = ianaCodeString.Trim().ToUpper(); if (IanaDict.TryGetValue(ianaCodeString, out IanaCode ianaCode)) { return(ianaCode); } throw new InvalidTimeZoneCode(ianaCodeString); }