}//Page_Load /// <summary>ListBoxRegistry_PreRender</summary> public void ListBoxRegistry_PreRender ( object sender, EventArgs e ) { string exceptionMessage = null; string[] registry = null; if ( !Page.IsPostBack ) { if ( ListBoxRegistry.Items.Count < 1 ) { UtilityString.ArrayCopy ( UtilityWhoIs.RegistryWhoIs, ref registry, UtilityWhoIs.RankRegistryWhoIsName, ref exceptionMessage ); if ( exceptionMessage != null ) { Feedback = exceptionMessage; } ListBoxRegistry.DataSource = registry; ListBoxRegistry.DataBind(); }//if ( ListBoxRegistry.Items.Count < 1 ) ListBoxRegistry.SelectedValue = registry[0]; }//if ( !Page.IsPostBack ) }//public void ListBoxRegistry_PreRender()
}//public static void Main() ///<summary>WhoisLookup</summary> public static void WhoisLookup ( ref UtilityWhoIsArgument utilityWhoIsArgument, ref StringBuilder[][] sb, ref string exceptionMessage ) { byte[] domainNameByte = null; bool registryDomainSuffixOnly = false; int domainIndex = -1; int registryIndex = -1; string domainName = null; string domainNameNewLine = null; string[] domainNameSplit = null; string readLine = null; string[] registry = null; string registryCurrent = null; HttpContext httpContext = HttpContext.Current; Stream stream = null; StreamReader streamReader = null; TcpClient tcpClient = null; try { if ( utilityWhoIsArgument.registry.Length > 0 ) { registry = utilityWhoIsArgument.registry; } else if ( utilityWhoIsArgument.registryDomainSuffixOnly == false ) { UtilityString.ArrayCopy( RegistryWhoIs, ref registry, RankRegistryWhoIsName, ref exceptionMessage ); if ( exceptionMessage != null ) { return; } } else { registryDomainSuffixOnly = true; } sb = new StringBuilder[utilityWhoIsArgument.domainName.Length][]; for ( domainIndex = 0; domainIndex < utilityWhoIsArgument.domainName.Length; ++domainIndex ) { domainName = utilityWhoIsArgument.domainName[domainIndex]; domainNameNewLine = domainName + Environment.NewLine; domainNameByte = Encoding.ASCII.GetBytes( domainNameNewLine.ToCharArray() ); if ( registryDomainSuffixOnly ) { domainNameSplit = domainName.Split('.'); registry = new string[1]; registry[0] = RegistryWhoIs[0][RankRegistryWhoIsName]; for ( int index = 0; index < RegistryWhoIs.Length; ++index ) { if ( RegistryWhoIs[index][RankRegistryWhoIsName].EndsWith( domainNameSplit[domainNameSplit.Length-1].ToLower() ) ) { registry[0] = RegistryWhoIs[index][RankRegistryWhoIsName]; break; }//if ( RegistryWhoIs[index][RankRegistryWhoIsName].EndsWith( domainNameSplit[domainNameSplit.Length-1].ToLower() ); }//for ( int index = 0; index < RegistryWhoIs.Length; ++index ) }//if ( registryDomainSuffixOnly == true ) sb[domainIndex] = new StringBuilder[registry.Length]; for ( registryIndex = 0; registryIndex < registry.Length; ++registryIndex ) { registryCurrent = registry[registryIndex]; tcpClient = new TcpClient( registryCurrent, utilityWhoIsArgument.port ); stream = tcpClient.GetStream(); stream.Write( domainNameByte, 0, domainNameNewLine.Length ); streamReader = new StreamReader( tcpClient.GetStream(), Encoding.ASCII ); sb[domainIndex][registryIndex] = new StringBuilder( registryCurrent); if ( httpContext == null ) { sb[domainIndex][registryIndex].Append( Environment.NewLine ); } else { sb[domainIndex][registryIndex].Append( "<br/>" ); } while ( true ) { readLine = streamReader.ReadLine(); if ( readLine == null ) { break; } if ( httpContext == null ) { System.Console.WriteLine( readLine ); } sb[domainIndex][registryIndex].Append( readLine ); if ( httpContext != null ) { sb[domainIndex][registryIndex].Append("<br/>"); } }//while ( true ) tcpClient.Close(); }//for ( registryIndex = 0; registryIndex < registry.Length; ++registryIndex ) }//foreach ( string domainName in utilityWhoIsArgument.domainName ) }//try catch ( SocketException exception ) { UtilityException.ExceptionLog( exception, exception.GetType().Name, ref exceptionMessage ); } catch ( Exception exception ) { UtilityException.ExceptionLog( exception, exception.GetType().Name, ref exceptionMessage ); } finally { if ( tcpClient != null ) { tcpClient.Close(); } }//finally }//WhoisLookup