@@ -20,8 +20,8 @@ static void Main(string[] args)
2020 //////////////////////////
2121 // Fill in your details //
2222 //////////////////////////
23- string username = "YOUR_USERNAME " ;
24- string password = "YOUR_PASSWORD " ;
23+ string username = "username " ;
24+ string password = "xxxxxxxxxx " ;
2525 string domain = "google.com" ;
2626
2727 /////////////////////////
@@ -152,19 +152,33 @@ public void PrintPairs()
152152 {
153153 try
154154 {
155- s = ( ( string ) subpair . Value ) . Replace ( "\n " , "" ) ;
155+ string valType = subpair . Value . GetType ( ) . ToString ( ) ;
156+ s = valType . Equals ( "System.Int32" )
157+ ? subpair . Value . ToString ( )
158+ : ( ( string ) subpair . Value ) . Replace ( "\n " , "" ) ;
156159 s = "\t " + subpair . Key + ": " + s . Substring ( 0 , ( s . Length < 40 ? s . Length : 40 ) ) + "\n " ;
157160 Console . Write ( s ) ;
158161 }
159162 catch ( Exception e2 )
160163 {
161164 Console . Write ( "\t " + subpair . Key + ":\n " ) ;
162165
163- foreach ( var subsubpair in subpair . Value as System . Collections . Generic . Dictionary < string , object > )
166+ try
164167 {
165- s = subsubpair . Value . ToString ( ) . Replace ( "\n " , "" ) ;
166- s = "\t \t " + subsubpair . Key + ": " + s . Substring ( 0 , ( s . Length < 40 ? s . Length : 40 ) ) + "\n " ;
167- Console . Write ( s ) ;
168+ foreach ( var subsubpair in subpair . Value as System . Collections . Generic . Dictionary < string , object > )
169+ {
170+ s = subsubpair . Value . ToString ( ) . Replace ( "\n " , "" ) ;
171+ if ( subsubpair . Value . GetType ( ) . ToString ( ) . Equals ( "System.Collections.ArrayList" ) ) {
172+ foreach ( var value in ( ArrayList ) subsubpair . Value )
173+ Console . Write ( "\t \t " + value . ToString ( ) + "\n " ) ;
174+ continue ;
175+ }
176+ s = "\t \t " + subsubpair . Key + ": " + s . Substring ( 0 , ( s . Length < 40 ? s . Length : 40 ) ) + "\n " ;
177+ Console . Write ( s ) ;
178+ }
179+ }
180+ catch ( Exception e3 ) {
181+ Console . Write ( subpair . Value + "\n " ) ;
168182 }
169183 }
170184 }
@@ -258,32 +272,36 @@ public void PrintToConsole()
258272 {
259273 Console . WriteLine ( "WhoisRecord:" ) ;
260274 Console . WriteLine ( "\t createdDate: " + createdDate ) ;
261- Console . WriteLine ( "\t expdatedDate : " + updatedDate ) ;
275+ Console . WriteLine ( "\t updatedDate : " + updatedDate ) ;
262276 Console . WriteLine ( "\t expiresDate: " + expiresDate ) ;
263277 Console . WriteLine ( "\t registrant:" ) ;
264- registrant . PrintToConsole ( ) ;
278+ registrant ? . PrintToConsole ( ) ;
265279 Console . WriteLine ( "\t administrativeContact:" ) ;
266- administrativeContact . PrintToConsole ( ) ;
280+ administrativeContact ? . PrintToConsole ( ) ;
267281 Console . WriteLine ( "\t billingContact:" ) ;
268- billingContact . PrintToConsole ( ) ;
282+ billingContact ? . PrintToConsole ( ) ;
269283 Console . WriteLine ( "\t technicalContact:" ) ;
270- technicalContact . PrintToConsole ( ) ;
284+ technicalContact ? . PrintToConsole ( ) ;
271285 Console . WriteLine ( "\t technicalContact:" ) ;
272- technicalContact . PrintToConsole ( ) ;
286+ technicalContact ? . PrintToConsole ( ) ;
273287 Console . WriteLine ( "\t zoneContact:" ) ;
274- zoneContact . PrintToConsole ( ) ;
288+ zoneContact ? . PrintToConsole ( ) ;
275289 Console . WriteLine ( "\t domainName: " + domainName ) ;
276290 Console . WriteLine ( "\t nameServers:" ) ;
277- nameServers . PrintToConsole ( ) ;
278- Console . WriteLine ( "\t rawText: " + rawText . Substring ( 0 , rawText . Length < 40 ? rawText . Length : 40 ) . Replace ( "\n " , "" ) ) ;
279- Console . WriteLine ( "\t header: " + header . Substring ( 0 , header . Length < 40 ? header . Length : 40 ) . Replace ( "\n " , "" ) ) ;
280- Console . WriteLine ( "\t strippedText: " + strippedText . Substring ( 0 , strippedText . Length < 40 ? strippedText . Length : 40 ) . Replace ( "\n " , "" ) ) ;
281- Console . WriteLine ( "\t footer: " + footer . Substring ( 0 , footer . Length < 40 ? footer . Length : 40 ) . Replace ( "\n " , "" ) ) ;
291+ nameServers ? . PrintToConsole ( ) ;
292+ string str = rawText ?? "" ;
293+ Console . WriteLine ( "\t rawText: " + str . Substring ( 0 , str . Length < 40 ? str . Length : 40 ) . Replace ( "\n " , "" ) ) ;
294+ str = header ?? "" ;
295+ Console . WriteLine ( "\t header: " + str . Substring ( 0 , str . Length < 40 ? str . Length : 40 ) . Replace ( "\n " , "" ) ) ;
296+ str = strippedText ?? "" ;
297+ Console . WriteLine ( "\t strippedText: " + str . Substring ( 0 , str . Length < 40 ? str . Length : 40 ) . Replace ( "\n " , "" ) ) ;
298+ str = footer ?? "" ;
299+ Console . WriteLine ( "\t footer: " + str . Substring ( 0 , str . Length < 40 ? str . Length : 40 ) . Replace ( "\n " , "" ) ) ;
282300 Console . WriteLine ( "\t audit:" ) ;
283- audit . PrintToConsole ( ) ;
301+ audit ? . PrintToConsole ( ) ;
284302 Console . WriteLine ( "\t registrarName: " + registrarName ) ;
285303 Console . WriteLine ( "\t registryData:" ) ;
286- registryData . PrintToConsole ( ) ;
304+ registryData ? . PrintToConsole ( ) ;
287305 Console . WriteLine ( "\t domainAvailability: " + domainAvailability ) ;
288306 Console . WriteLine ( "\t contactEmail: " + contactEmail ) ;
289307 Console . WriteLine ( "\t domainNameExt: " + domainNameExt ) ;
@@ -340,23 +358,33 @@ public class WhoisRecordNameServers
340358 {
341359 [ System . Xml . Serialization . XmlElement ( "rawText" ) ]
342360 public string rawText { get ; set ; }
343- [ System . Xml . Serialization . XmlElement ( "Address " ) ]
344- public List < string > hostNames { get ; set ; }
345- [ System . Xml . Serialization . XmlElement ( "class " ) ]
346- public List < string > ips { get ; set ; }
361+ [ System . Xml . Serialization . XmlElement ( "hostNames " ) ]
362+ public WhoisHosts hostNames { get ; set ; }
363+ [ System . Xml . Serialization . XmlElement ( "ips " ) ]
364+ public WhoisHosts ips { get ; set ; }
347365
348366 public void PrintToConsole ( )
349367 {
350- Console . WriteLine ( "\t \t rawText: " + rawText . Substring ( 0 , ( rawText . Length < 40 ? rawText . Length : 40 ) ) . Replace ( "\n " , "" ) ) ;
368+ string str = rawText ?? "" ;
369+ Console . WriteLine ( "\t \t rawText: " + str . Substring ( 0 , ( str . Length < 40 ? str . Length : 40 ) ) . Replace ( "\n " , "" ) ) ;
370+
351371 Console . WriteLine ( "\t \t hostNames:" ) ;
352- foreach ( string hostname in hostNames )
372+ foreach ( string hostname in hostNames ? . Items )
353373 Console . WriteLine ( "\t \t \t " + hostname ) ;
374+
354375 Console . WriteLine ( "\t \t ips:\n " ) ;
355- foreach ( string ip in ips )
376+ foreach ( string ip in ips ? . Items )
356377 Console . WriteLine ( "\t \t \t " + ip ) ;
357378 }
358379 }
359380
381+ [ Serializable ( ) ]
382+ public class WhoisHosts
383+ {
384+ [ System . Xml . Serialization . XmlElement ( "Address" ) ]
385+ public List < string > Items { get ; set ; }
386+ }
387+
360388 [ Serializable ( ) ]
361389 public class WhoisRecordAudit
362390 {
@@ -426,25 +454,25 @@ public void PrintToConsole()
426454 Console . WriteLine ( "\t \t updatedDate: " + updatedDate ) ;
427455 Console . WriteLine ( "\t \t expiresDate: " + expiresDate ) ;
428456 Console . WriteLine ( "\t \t registrant:" ) ;
429- registrant . PrintToConsole ( ) ;
457+ registrant ? . PrintToConsole ( ) ;
430458 Console . WriteLine ( "\t \t administrativeContact:" ) ;
431- administrativeContact . PrintToConsole ( ) ;
459+ administrativeContact ? . PrintToConsole ( ) ;
432460 Console . WriteLine ( "\t \t billingContact:" ) ;
433- billingContact . PrintToConsole ( ) ;
461+ billingContact ? . PrintToConsole ( ) ;
434462 Console . WriteLine ( "\t \t technicalContact:" ) ;
435- technicalContact . PrintToConsole ( ) ;
463+ technicalContact ? . PrintToConsole ( ) ;
436464 Console . WriteLine ( "\t \t zoneContact:" ) ;
437- zoneContact . PrintToConsole ( ) ;
465+ zoneContact ? . PrintToConsole ( ) ;
438466 Console . WriteLine ( "\t \t domainName: " + domainName ) ;
439467 Console . WriteLine ( "\t \t nameServers:" ) ;
440- nameServers . PrintToConsole ( ) ;
468+ nameServers ? . PrintToConsole ( ) ;
441469 Console . WriteLine ( "\t \t status: " + status . Substring ( 0 , ( status . Length < 40 ? status . Length : 40 ) ) . Replace ( "\n " , "" ) ) ;
442470 Console . WriteLine ( "\t \t rawText: " + rawText . Substring ( 0 , ( rawText . Length < 40 ? rawText . Length : 40 ) ) . Replace ( "\n " , "" ) ) ;
443471 Console . WriteLine ( "\t \t header: " + header . Substring ( 0 , ( header . Length < 40 ? header . Length : 40 ) ) . Replace ( "\n " , "" ) ) ;
444472 Console . WriteLine ( "\t \t strippedText: " + strippedText . Substring ( 0 , ( strippedText . Length < 40 ? strippedText . Length : 40 ) ) . Replace ( "\n " , "" ) ) ;
445473 Console . WriteLine ( "\t \t footer: " + footer . Substring ( 0 , ( footer . Length < 40 ? footer . Length : 40 ) ) . Replace ( "\n " , "" ) ) ;
446474 Console . WriteLine ( "\t \t audit:" ) ;
447- audit . PrintToConsole ( ) ;
475+ audit ? . PrintToConsole ( ) ;
448476 Console . WriteLine ( "\t \t registrarName: " + registrarName ) ;
449477 Console . WriteLine ( "\t \t whoisServer: " + whoisServer ) ;
450478 Console . WriteLine ( "\t \t referralURL: " + referralURL ) ;
0 commit comments