/// <summary> /// Parses the WHOIS server response for the given server and TLD. /// </summary> public WhoisResponse Parse(string whoisServer, string tld, string content) { LoadServerTemplates(whoisServer, tld); LoadServerTemplates(whoisServer); var result = matcher.Match <WhoisResponse>(content, new [] { whoisServer, tld }); var match = result.BestMatch; if (match == null) { LoadServerGenericTemplates(); match = matcher .Match <WhoisResponse>(content, new [] { "catch-all" }) .BestMatch; } if (match != null) { var value = match.Value; value.FieldsParsed = match.Tokens.Matches.Count; value.ParsingErrors = match.Exceptions.Count; value.TemplateName = match.Template.Name; var status = statusParser.Parse(whoisServer, tld, value.DomainStatus.FirstOrDefault(), value.Status); value.Status = status; return(value); } return(null); }
/// <summary> /// Parses the WHOIS server response for the given server and TLD. /// </summary> public WhoisResponse Parse(string whoisServer, string content) { LoadServerTemplates(whoisServer); var result = matcher.Match <WhoisResponse>(content, new [] { whoisServer }); var match = result.BestMatch; if (match == null) { LoadServerGenericTemplates(); match = matcher .Match <WhoisResponse>(content, new [] { "catch-all" }) .BestMatch; } if (match != null) { // Perform extended processing on parsed data // via FixUps. foreach (var fixup in FixUps) { if (fixup.CanFixup(match)) { fixup.Fixup(match); } } var value = match.Value; value.Content = content; value.FieldsParsed = match.Tokens.Matches.Count; value.ParsingErrors = match.Exceptions.Count; value.TemplateName = match.Template.Name; var status = statusParser.Parse(whoisServer, value.DomainStatus.FirstOrDefault(), value.Status); value.Status = status; return(value); } return(new WhoisResponse { Content = content, Status = WhoisStatus.Unknown }); }