Exemplo n.º 1
0
        //// =====================================================================================

        /// <summary>
        /// Obtient des informations sur le nom de domaine de deuxième niveau spécifié.
        /// </summary>
        /// <remarks>
        /// Cette méthode sélectionne automatiquement le service de recherche Whois approprié en fonction du domaine de haut niveau présent dans le nom de domaine spécifié.
        /// </remarks>
        /// <param name="domain">Nom de domaine de deuxième niveau à rechercher.</param>
        /// <returns>Résultat de l'interrogation du service de recherche Whois sur l'hôte distant.</returns>
        /// <exception cref="ArgumentException">Le nom de domaine spécifié est invalide ou une référence null.</exception>
        public static string GetHostInfo(string domain)
        {
            if (string.IsNullOrEmpty(domain))
            {
                throw new ArgumentException(Resources.EmptyDomainName, "domain");
            }

            // Détermination du domaine de haut niveau
            var index = domain.LastIndexOf('.');

            if (index <= 0)
            {
                throw new ArgumentException(Resources.InvalidDomainName, "domain");
            }

            var tld = domain.Substring(index + 1);

            if (!knownServers.ContainsKey(tld))
            {
                throw new ArgumentException(Resources.UnknownTopLevelDomain, "domain");
            }

            // Interrogation du serveur Whois
            using (var client = new WhoisClient(knownServers[tld])) return(client.Lookup(domain));
        }
Exemplo n.º 2
0
		//// =====================================================================================

		/// <summary>
		/// Obtient des informations sur le nom de domaine de deuxième niveau spécifié.
		/// </summary>
		/// <remarks>
		/// Cette méthode sélectionne automatiquement le service de recherche Whois approprié en fonction du domaine de haut niveau présent dans le nom de domaine spécifié.
		/// </remarks>
		/// <param name="domain">Nom de domaine de deuxième niveau à rechercher.</param>
		/// <returns>Résultat de l'interrogation du service de recherche Whois sur l'hôte distant.</returns>
		/// <exception cref="ArgumentException">Le nom de domaine spécifié est invalide ou une référence null.</exception>
		public static string GetHostInfo(string domain)
		{
			if(string.IsNullOrEmpty(domain)) throw new ArgumentException(Resources.EmptyDomainName, "domain");

			// Détermination du domaine de haut niveau
			var index=domain.LastIndexOf('.');
			if(index<=0) throw new ArgumentException(Resources.InvalidDomainName, "domain");
			
			var tld=domain.Substring(index+1);
			if(!knownServers.ContainsKey(tld)) throw new ArgumentException(Resources.UnknownTopLevelDomain, "domain");

			// Interrogation du serveur Whois
			using(var client=new WhoisClient(knownServers[tld])) return client.Lookup(domain);
		}