/// <summary> /// Checks whether the given TLD is in the List <see cref="TLDs"/>. /// </summary> /// <param name="tld">The given TLD.</param> /// <param name="timeSpan">Timespan to wait for Reload data.</param> /// <returns><c>true</c> if listed, otherwise <c>false</c>.</returns> public static bool StaticCheckTLD(string tld, TimeSpan timeSpan) { if (timeSpan != default) { ReloadData(timeSpan); } return(TLDs.Contains(tld.Trim().ToUpper())); }
/// <summary> /// Gets the data from IANA. /// </summary> /// <returns>The amount of loaded TLDs.</returns> private static int GetDataFromIANA() { int result = 0; DateTime start = DateTime.Now; DateTime end; IRestRequest request = new RestRequest(Path, Method.GET, DataFormat.None); IRestResponse response = RestClient.Execute(request); string[] lines = null; IHeadline oldHeadline = LastAnswer; LastResponseStatus = response.ResponseStatus; if (response.ResponseStatus == ResponseStatus.Completed || response.ResponseStatus == ResponseStatus.None) { lines = response.Content.Split('\n'); } if (lines != null && lines.Length > 1) { result = lines.Length; LastAnswer = new Headline(lines[0].Trim()); if (oldHeadline != null && !LastAnswer.Version.Equals(oldHeadline.Version)) { // the whole idea with reload is nice - but if there was no // change, it isn't needes... TLDs.Clear(); for (int i = 1; i < lines.Length; i++) { TLDs.Add(lines[i].Trim()); } } else if (oldHeadline == null) { for (int i = 1; i < lines.Length; i++) { TLDs.Add(lines[i].Trim()); } } } end = DateTime.Now; LastReloadTime = end.Subtract(start); Reloads++; return(result); }
/// <summary> /// Checks whether the given TLD is in the List <see cref="TLDs"/>. /// </summary> /// <param name="tld">The given TLD.</param> /// <returns><c>true</c> if listed, otherwise <c>false</c>.</returns> public static bool StaticCheckTLD(string tld) { return(TLDs.Contains(tld.Trim().ToUpper())); }