-
Notifications
You must be signed in to change notification settings - Fork 0
/
CountryListBox_07.03.03.xml
588 lines (581 loc) · 30.1 KB
/
CountryListBox_07.03.03.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<root file="CountryListBox.dll" version="07.03.03" generated="2017-06-19 12:19:51Z" generationTime="1.4618139">
<namespace name="DotNetNuke.UI.WebControls">
<class name="CountryListBox">
<declaration><![CDATA[public class CountryListBox : DropDownList]]></declaration>
<documentation>
</documentation>
<constructors>
<constructor name=".ctor">
<declaration><![CDATA[private bool _CacheGeoIPData = true;]]></declaration>
<documentation>
</documentation>
<codeblock>
<location sl="46" sc="9" el="46" ec="45">CountryListBox.cs</location>
<body hash="10983c0c79492bbd2b2be65a26f1c5d3"><![CDATA[private bool _CacheGeoIPData = true]]></body>
</codeblock>
</constructor>
</constructors>
<methods>
<method name="OnDataBinding">
<declaration><![CDATA[protected override void OnDataBinding(EventArgs e)]]></declaration>
<documentation>
</documentation>
<codeblock>
<location sl="108" sc="9" el="206" ec="10">CountryListBox.cs</location>
<body hash="97422367932612c1ef4df5af2d26f315"><![CDATA[{
bool IsLocal = false;
string IP;
if (!Page.IsPostBack)
{
//If GeoIPFile is not provided, assume they put it in BIN.
if (String.IsNullOrEmpty(_GeoIPFile))
{
_GeoIPFile = "controls/CountryListBox/Data/GeoIP.dat";
}
EnsureChildControls();
//Check to see if a TestIP is specified
if (!String.IsNullOrEmpty(_TestIP))
{
//TestIP is specified, let's use it
IP = _TestIP;
}
else if (Page.Request.UserHostAddress == "127.0.0.1")
{
//The country cannot be detected because the user is local.
IsLocal = true;
//Set the IP address in case they didn't specify LocalhostCountryCode
IP = Page.Request.UserHostAddress;
}
else
{
//Set the IP address so we can find the country
IP = Page.Request.UserHostAddress;
}
//Check to see if we need to generate the Cache for the GeoIPData file
if (Context.Cache.Get("GeoIPData") == null && _CacheGeoIPData)
{
//Store it as well as setting a dependency on the file
Context.Cache.Insert("GeoIPData", CountryLookup.FileToMemory(Context.Server.MapPath(_GeoIPFile)), new CacheDependency(Context.Server.MapPath(_GeoIPFile)));
}
//Check to see if the request is a localhost request
//and see if the LocalhostCountryCode is specified
if (IsLocal && !String.IsNullOrEmpty(_LocalhostCountryCode))
{
//Bing the data
base.OnDataBinding(e);
//Pre-Select the value in the drop-down based
//on the LocalhostCountryCode specified.
if (Items.FindByValue(_LocalhostCountryCode) != null)
{
Items.FindByValue(_LocalhostCountryCode).Selected = true;
}
}
else
{
//Either this is a remote request or it is a local
//request with no LocalhostCountryCode specified
CountryLookup _CountryLookup;
//Check to see if we are using the Cached
//version of the GeoIPData file
if (_CacheGeoIPData)
{
//Yes, get it from cache
_CountryLookup = new CountryLookup((MemoryStream) Context.Cache.Get("GeoIPData"));
}
else
{
//No, get it from file
_CountryLookup = new CountryLookup(Context.Server.MapPath(_GeoIPFile));
}
//Get the country code based on the IP address
string _UserCountryCode = _CountryLookup.LookupCountryCode(IP);
//Bind the datasource
base.OnDataBinding(e);
//Make sure the value returned is actually
//in the drop-down list.
if (Items.FindByValue(_UserCountryCode) != null)
{
//Yes, it's there, select it based on its value
Items.FindByValue(_UserCountryCode).Selected = true;
}
else
{
//No it's not there. Let's get the Country description
//and add a new list item for the Country detected
string _UserCountry = _CountryLookup.LookupCountryName(IP);
if (_UserCountry != "N/A")
{
var newItem = new ListItem();
newItem.Value = _UserCountryCode;
newItem.Text = _UserCountry;
Items.Insert(0, newItem);
//Now let's Pre-Select it
Items.FindByValue(_UserCountryCode).Selected = true;
}
}
}
}
}]]></body>
</codeblock>
</method>
</methods>
<fields>
<field name="_CacheGeoIPData">
<declaration><![CDATA[private bool _CacheGeoIPData = true;]]></declaration>
<documentation>
</documentation>
</field>
<field name="_GeoIPFile">
<declaration><![CDATA[private string _GeoIPFile;]]></declaration>
<documentation>
</documentation>
</field>
<field name="_LocalhostCountryCode">
<declaration><![CDATA[private string _LocalhostCountryCode;]]></declaration>
<documentation>
</documentation>
</field>
<field name="_TestIP">
<declaration><![CDATA[private string _TestIP;]]></declaration>
<documentation>
</documentation>
</field>
</fields>
<properties>
<property name="CacheGeoIPData">
<declaration><![CDATA[public bool CacheGeoIPData]]></declaration>
<documentation>
</documentation>
<codeblock>
<location sl="55" sc="13" el="57" ec="14">CountryListBox.cs</location>
<body hash="47bf18966a359f7d6fc342f9ca73c7c0"><![CDATA[{
return _CacheGeoIPData;
}]]></body>
</codeblock>
<codeblock>
<location sl="59" sc="13" el="65" ec="14">CountryListBox.cs</location>
<body hash="50727fcb61d232651ed3ffc98ab0c102"><![CDATA[{
_CacheGeoIPData = value;
if (value == false)
{
Context.Cache.Remove("GeoIPData");
}
}]]></body>
</codeblock>
</property>
<property name="GeoIPFile">
<declaration><![CDATA[public string GeoIPFile]]></declaration>
<documentation>
</documentation>
<codeblock>
<location sl="72" sc="13" el="74" ec="14">CountryListBox.cs</location>
<body hash="1f334826112ee36e1a4f37d5c163772a"><![CDATA[{
return _GeoIPFile;
}]]></body>
</codeblock>
<codeblock>
<location sl="76" sc="13" el="78" ec="14">CountryListBox.cs</location>
<body hash="3cb4ffd21e593436440d37de422da042"><![CDATA[{
_GeoIPFile = value;
}]]></body>
</codeblock>
</property>
<property name="LocalhostCountryCode">
<declaration><![CDATA[public string LocalhostCountryCode]]></declaration>
<documentation>
</documentation>
<codeblock>
<location sl="98" sc="13" el="100" ec="14">CountryListBox.cs</location>
<body hash="bc538bc75dec4d1a5f8aff0e8a3d8478"><![CDATA[{
return _LocalhostCountryCode;
}]]></body>
</codeblock>
<codeblock>
<location sl="102" sc="13" el="104" ec="14">CountryListBox.cs</location>
<body hash="2c8ca88d55078b2f62315385570a0733"><![CDATA[{
_LocalhostCountryCode = value;
}]]></body>
</codeblock>
</property>
<property name="TestIP">
<declaration><![CDATA[public string TestIP]]></declaration>
<documentation>
</documentation>
<codeblock>
<location sl="85" sc="13" el="87" ec="14">CountryListBox.cs</location>
<body hash="bea93da43c9ba5c458450df2db22397e"><![CDATA[{
return _TestIP;
}]]></body>
</codeblock>
<codeblock>
<location sl="89" sc="13" el="91" ec="14">CountryListBox.cs</location>
<body hash="bd164423dbeced08b7b9843988200967"><![CDATA[{
_TestIP = value;
}]]></body>
</codeblock>
</property>
</properties>
<events>
</events>
</class>
<class name="CountryLookup">
<declaration><![CDATA[public class CountryLookup]]></declaration>
<documentation>
</documentation>
<constructors>
<constructor name=".ctor">
<declaration><![CDATA[public CountryLookup(MemoryStream ms)]]></declaration>
<documentation>
</documentation>
<codeblock>
<location sl="92" sc="9" el="95" ec="10">CountryLookup.cs</location>
<body hash="c8d02d953f7a8f1908cf06044a8c78a0"><![CDATA[public CountryLookup(MemoryStream ms)
{
m_MemoryStream = ms;
}]]></body>
</codeblock>
</constructor>
<constructor name=".ctor">
<declaration><![CDATA[public CountryLookup(string FileLocation)]]></declaration>
<documentation>
</documentation>
<codeblock>
<location sl="97" sc="9" el="110" ec="10">CountryLookup.cs</location>
<body hash="19b900daff4c6db833a7e53acc54127f"><![CDATA[public CountryLookup(string FileLocation)
{
//------------------------------------------------------------------------------------------------
//Load the passed in GeoIP Data file to the memorystream
//------------------------------------------------------------------------------------------------
var _FileStream = new FileStream(FileLocation, FileMode.Open, FileAccess.Read);
m_MemoryStream = new MemoryStream();
var _Byte = new byte[256];
while (_FileStream.Read(_Byte, 0, _Byte.Length) != 0)
{
m_MemoryStream.Write(_Byte, 0, _Byte.Length);
}
_FileStream.Close();
}]]></body>
</codeblock>
</constructor>
<constructor name=".cctor">
<declaration><![CDATA[static CountryLookup()]]></declaration>
<documentation>
</documentation>
<codeblock>
<location sl="40" sc="9" el="88" ec="62">CountryLookup.cs</location>
<body hash="249a91f9d82b7dc9d12d00261ec48bf8"><![CDATA[private static long CountryBegin = 16776960;
private static readonly string[] CountryName = new[]
{
"N/A", "Asia/Pacific Region", "Europe", "Andorra", "United Arab Emirates", "Afghanistan", "Antigua and Barbuda", "Anguilla", "Albania",
"Armenia", "Netherlands Antilles", "Angola", "Antarctica", "Argentina", "American Samoa", "Austria", "Australia", "Aruba", "Azerbaijan",
"Bosnia and Herzegovina", "Barbados", "Bangladesh", "Belgium", "Burkina Faso", "Bulgaria", "Bahrain", "Burundi", "Benin", "Bermuda",
"Brunei Darussalam", "Bolivia", "Brazil", "Bahamas", "Bhutan", "Bouvet Island", "Botswana", "Belarus", "Belize", "Canada",
"Cocos (Keeling) Islands", "Congo, The Democratic Republic of the", "Central African Republic", "Congo", "Switzerland", "Cote D'Ivoire",
"Cook Islands", "Chile", "Cameroon", "China", "Colombia", "Costa Rica", "Cuba", "Cape Verde", "Christmas Island", "Cyprus", "Czech Republic"
, "Germany", "Djibouti", "Denmark", "Dominica", "Dominican Republic", "Algeria", "Ecuador", "Estonia", "Egypt", "Western Sahara", "Eritrea",
"Spain", "Ethiopia", "Finland", "Fiji", "Falkland Islands (Malvinas)", "Micronesia, Federated States of", "Faroe Islands", "France",
"France, Metropolitan", "Gabon", "United Kingdom", "Grenada", "Georgia", "French Guiana", "Ghana", "Gibraltar", "Greenland", "Gambia",
"Guinea", "Guadeloupe", "Equatorial Guinea", "Greece", "South Georgia and the South Sandwich Islands", "Guatemala", "Guam", "Guinea-Bissau",
"Guyana", "Hong Kong", "Heard Island and McDonald Islands", "Honduras", "Croatia", "Haiti", "Hungary", "Indonesia", "Ireland", "Israel",
"India", "British Indian Ocean Territory", "Iraq", "Iran, Islamic Republic of", "Iceland", "Italy", "Jamaica", "Jordan", "Japan", "Kenya",
"Kyrgyzstan", "Cambodia", "Kiribati", "Comoros", "Saint Kitts and Nevis", "Korea, Democratic People's Republic of", "Korea, Republic of",
"Kuwait", "Cayman Islands", "Kazakstan", "Lao People's Democratic Republic", "Lebanon", "Saint Lucia", "Liechtenstein", "Sri Lanka",
"Liberia", "Lesotho", "Lithuania", "Luxembourg", "Latvia", "Libyan Arab Jamahiriya", "Morocco", "Monaco", "Moldova, Republic of",
"Madagascar", "Marshall Islands", "Macedonia, the Former Yugoslav Republic of", "Mali", "Myanmar", "Mongolia", "Macau",
"Northern Mariana Islands", "Martinique", "Mauritania", "Montserrat", "Malta", "Mauritius", "Maldives", "Malawi", "Mexico", "Malaysia",
"Mozambique", "Namibia", "New Caledonia", "Niger", "Norfolk Island", "Nigeria", "Nicaragua", "Netherlands", "Norway", "Nepal", "Nauru",
"Niue", "New Zealand", "Oman", "Panama", "Peru", "French Polynesia", "Papua New Guinea", "Philippines", "Pakistan", "Poland",
"Saint Pierre and Miquelon", "Pitcairn", "Puerto Rico", "Palestinian Territory, Occupied", "Portugal", "Palau", "Paraguay", "Qatar",
"Reunion", "Romania", "Russian Federation", "Rwanda", "Saudi Arabia", "Solomon Islands", "Seychelles", "Sudan", "Sweden", "Singapore",
"Saint Helena", "Slovenia", "Svalbard and Jan Mayen", "Slovakia", "Sierra Leone", "San Marino", "Senegal", "Somalia", "Suriname",
"Sao Tome and Principe", "El Salvador", "Syrian Arab Republic", "Swaziland", "Turks and Caicos Islands", "Chad",
"French Southern Territories", "Togo", "Thailand", "Tajikistan", "Tokelau", "Turkmenistan", "Tunisia", "Tonga", "East Timor", "Turkey",
"Trinidad and Tobago", "Tuvalu", "Taiwan, Province of China", "Tanzania, United Republic of", "Ukraine", "Uganda",
"United States Minor Outlying Islands", "United States", "Uruguay", "Uzbekistan", "Holy See (Vatican City State)",
"Saint Vincent and the Grenadines", "Venezuela", "Virgin Islands, British", "Virgin Islands, U.S.", "Vietnam", "Vanuatu",
"Wallis and Futuna", "Samoa", "Yemen", "Mayotte", "Yugoslavia", "South Africa", "Zambia", "Zaire", "Zimbabwe", "Anonymous Proxy",
"Satellite Provider"
};
private static readonly string[] CountryCode = new[]
{
"--", "AP", "EU", "AD", "AE", "AF", "AG", "AI", "AL", "AM", "AN", "AO", "AQ", "AR", "AS", "AT", "AU", "AW", "AZ", "BA", "BB", "BD", "BE",
"BF", "BG", "BH", "BI", "BJ", "BM", "BN", "BO", "BR", "BS", "BT", "BV", "BW", "BY", "BZ", "CA", "CC", "CD", "CF", "CG", "CH", "CI", "CK",
"CL", "CM", "CN", "CO", "CR", "CU", "CV", "CX", "CY", "CZ", "DE", "DJ", "DK", "DM", "DO", "DZ", "EC", "EE", "EG", "EH", "ER", "ES", "ET",
"FI", "FJ", "FK", "FM", "FO", "FR", "FX", "GA", "GB", "GD", "GE", "GF", "GH", "GI", "GL", "GM", "GN", "GP", "GQ", "GR", "GS", "GT", "GU",
"GW", "GY", "HK", "HM", "HN", "HR", "HT", "HU", "ID", "IE", "IL", "IN", "IO", "IQ", "IR", "IS", "IT", "JM", "JO", "JP", "KE", "KG", "KH",
"KI", "KM", "KN", "KP", "KR", "KW", "KY", "KZ", "LA", "LB", "LC", "LI", "LK", "LR", "LS", "LT", "LU", "LV", "LY", "MA", "MC", "MD", "MG",
"MH", "MK", "ML", "MM", "MN", "MO", "MP", "MQ", "MR", "MS", "MT", "MU", "MV", "MW", "MX", "MY", "MZ", "NA", "NC", "NE", "NF", "NG", "NI",
"NL", "NO", "NP", "NR", "NU", "NZ", "OM", "PA", "PE", "PF", "PG", "PH", "PK", "PL", "PM", "PN", "PR", "PS", "PT", "PW", "PY", "QA", "RE",
"RO", "RU", "RW", "SA", "SB", "SC", "SD", "SE", "SG", "SH", "SI", "SJ", "SK", "SL", "SM", "SN", "SO", "SR", "ST", "SV", "SY", "SZ", "TC",
"TD", "TF", "TG", "TH", "TJ", "TK", "TM", "TN", "TO", "TP", "TR", "TT", "TV", "TW", "TZ", "UA", "UG", "UM", "US", "UY", "UZ", "VA", "VC",
"VE", "VG", "VI", "VN", "VU", "WF", "WS", "YE", "YT", "YU", "ZA", "ZM", "ZR", "ZW", "A1", "A2"
};]]></body>
</codeblock>
</constructor>
</constructors>
<methods>
<method name="ConvertIPAddressToNumber">
<declaration><![CDATA[private long ConvertIPAddressToNumber(IPAddress _IPAddress)]]></declaration>
<documentation>
</documentation>
<codeblock>
<location sl="113" sc="9" el="124" ec="10">CountryLookup.cs</location>
<body hash="ebae02fef21f9d3aa8e0d09a725322a1"><![CDATA[{
//Convert an IP Address, (e.g. 127.0.0.1), to the numeric equivalent
string[] _Address = _IPAddress.ToString().Split('.');
if (_Address.Length == 4)
{
return Convert.ToInt64(16777216*Convert.ToDouble(_Address[0]) + 65536*Convert.ToDouble(_Address[1]) + 256*Convert.ToDouble(_Address[2]) + Convert.ToDouble(_Address[3]));
}
else
{
return 0;
}
}]]></body>
</codeblock>
</method>
<method name="ConvertIPNumberToAddress">
<declaration><![CDATA[private string ConvertIPNumberToAddress(long _IPNumber)]]></declaration>
<documentation>
</documentation>
<codeblock>
<location sl="127" sc="9" el="134" ec="10">CountryLookup.cs</location>
<body hash="1be108a1dc503b58cac77037f325e328"><![CDATA[{
//Convert an IP Number to the IP Address equivalent
string _IPNumberPart1 = Convert.ToString(((int) (_IPNumber/16777216))%256);
string _IPNumberPart2 = Convert.ToString(((int) (_IPNumber/65536))%256);
string _IPNumberPart3 = Convert.ToString(((int) (_IPNumber/256))%256);
string _IPNumberPart4 = Convert.ToString(((int) (_IPNumber))%256);
return _IPNumberPart1 + "." + _IPNumberPart2 + "." + _IPNumberPart3 + "." + _IPNumberPart4;
}]]></body>
</codeblock>
</method>
<method name="FileToMemory">
<declaration><![CDATA[public static MemoryStream FileToMemory(string FileLocation)]]></declaration>
<documentation>
</documentation>
<codeblock>
<location sl="137" sc="9" el="157" ec="10">CountryLookup.cs</location>
<body hash="522b261ae2deffcbf4fd8104ad1d36b3"><![CDATA[{
//Read a given file into a Memory Stream to return as the result
FileStream _FileStream;
var _MemStream = new MemoryStream();
var _Byte = new byte[256];
try
{
_FileStream = new FileStream(FileLocation, FileMode.Open, FileAccess.Read);
while (_FileStream.Read(_Byte, 0, _Byte.Length) != 0)
{
_MemStream.Write(_Byte, 0, _Byte.Length);
}
_FileStream.Close();
}
catch (FileNotFoundException exc)
{
throw new Exception(exc.Message +
" Please set the \"GeoIPFile\" Property to specify the location of this file. The property value must be set to the virtual path to GeoIP.dat (i.e. \"/controls/CountryListBox/Data/GeoIP.dat\")");
}
return _MemStream;
}]]></body>
</codeblock>
</method>
<method name="LookupCountryCode">
<declaration><![CDATA[public string LookupCountryCode(IPAddress _IPAddress)]]></declaration>
<documentation>
</documentation>
<codeblock>
<location sl="160" sc="9" el="163" ec="10">CountryLookup.cs</location>
<body hash="ce3963f5b53eee5270267e474e7bebc5"><![CDATA[{
//Look up the country code, e.g. US, for the passed in IP Address
return CountryCode[Convert.ToInt32(SeekCountry(0, ConvertIPAddressToNumber(_IPAddress), 31))];
}]]></body>
</codeblock>
</method>
<method name="LookupCountryCode">
<declaration><![CDATA[public string LookupCountryCode(string _IPAddress)]]></declaration>
<documentation>
</documentation>
<codeblock>
<location sl="166" sc="9" el="178" ec="10">CountryLookup.cs</location>
<body hash="e6b1cf7b8e621d708296ec84cc607da8"><![CDATA[{
//Look up the country code, e.g. US, for the passed in IP Address
IPAddress _Address;
try
{
_Address = IPAddress.Parse(_IPAddress);
}
catch (FormatException)
{
return "--";
}
return LookupCountryCode(_Address);
}]]></body>
</codeblock>
</method>
<method name="LookupCountryName">
<declaration><![CDATA[public string LookupCountryName(IPAddress addr)]]></declaration>
<documentation>
</documentation>
<codeblock>
<location sl="181" sc="9" el="184" ec="10">CountryLookup.cs</location>
<body hash="907f8122adb25de38e60b75633ed8a6a"><![CDATA[{
//Look up the country name, e.g. United States, for the IP Address
return CountryName[Convert.ToInt32(SeekCountry(0, ConvertIPAddressToNumber(addr), 31))];
}]]></body>
</codeblock>
</method>
<method name="LookupCountryName">
<declaration><![CDATA[public string LookupCountryName(string _IPAddress)]]></declaration>
<documentation>
</documentation>
<codeblock>
<location sl="187" sc="9" el="199" ec="10">CountryLookup.cs</location>
<body hash="ef5da08f44dbda02ca48163acaff6896"><![CDATA[{
//Look up the country name, e.g. United States, for the IP Address
IPAddress _Address;
try
{
_Address = IPAddress.Parse(_IPAddress);
}
catch (FormatException)
{
return "N/A";
}
return LookupCountryName(_Address);
}]]></body>
</codeblock>
</method>
<method name="SeekCountry">
<declaration><![CDATA[public int SeekCountry(int Offset, long Ipnum, short Depth)]]></declaration>
<documentation>
</documentation>
<codeblock>
<location sl="236" sc="9" el="284" ec="10">CountryLookup.cs</location>
<body hash="51b688b5f0d1b7a2e5b22cb8dcb4e1a2"><![CDATA[{
try
{
var Buffer = new byte[6];
var X = new int[2];
short I;
short J;
byte Y;
if (Depth == 0)
{
throw new Exception();
}
m_MemoryStream.Seek(6*Offset, 0);
m_MemoryStream.Read(Buffer, 0, 6);
for (I = 0; I <= 1; I++)
{
X[I] = 0;
for (J = 0; J <= 2; J++)
{
Y = Buffer[I*3 + J];
if (Y < 0)
{
Y = Convert.ToByte(Y + 256);
}
X[I] = Convert.ToInt32(X[I] + vbShiftLeft(Y, J*8));
}
}
if ((Ipnum & vbShiftLeft(1, Depth)) > 0)
{
if (X[1] >= CountryBegin)
{
return Convert.ToInt32(X[1] - CountryBegin);
}
return SeekCountry(X[1], Ipnum, Convert.ToInt16(Depth - 1));
}
else
{
if (X[0] >= CountryBegin)
{
return Convert.ToInt32(X[0] - CountryBegin);
}
return SeekCountry(X[0], Ipnum, Convert.ToInt16(Depth - 1));
}
}
catch (Exception exc)
{
throw new Exception("Error seeking country: " + exc.Message);
}
}]]></body>
</codeblock>
</method>
<method name="vbShiftLeft">
<declaration><![CDATA[private long vbShiftLeft(long value, int Count)]]></declaration>
<documentation>
</documentation>
<codeblock>
<location sl="202" sc="9" el="216" ec="10">CountryLookup.cs</location>
<body hash="36f1318f24a5a5af692806b7281a244b"><![CDATA[{
//------------------------------------------------------------------------------------------------
// Replacement for Bitwise operators which are missing in VB.NET,
// these functions are present in .NET 1.1, but for developers
// using 1.0, replacement functions must be implemented
//------------------------------------------------------------------------------------------------
long returnValue = 0;
int _Iterator;
returnValue = value;
for (_Iterator = 1; _Iterator <= Count; _Iterator++)
{
returnValue = returnValue*2;
}
return returnValue;
}]]></body>
</codeblock>
</method>
<method name="vbShiftRight">
<declaration><![CDATA[private long vbShiftRight(long value, int Count)]]></declaration>
<documentation>
</documentation>
<codeblock>
<location sl="219" sc="9" el="233" ec="10">CountryLookup.cs</location>
<body hash="9767a6735113c2ebbb4bb7b3b3da5f1d"><![CDATA[{
//------------------------------------------------------------------------------------------------
// Replacement for Bitwise operators which are missing in VB.NET,
// these functions are present in .NET 1.1, but for developers
// using 1.0, replacement functions must be implemented
//------------------------------------------------------------------------------------------------
long returnValue = 0;
int _Iterator;
returnValue = value;
for (_Iterator = 1; _Iterator <= Count; _Iterator++)
{
returnValue = returnValue/2;
}
return returnValue;
}]]></body>
</codeblock>
</method>
</methods>
<fields>
<field name="CountryBegin">
<declaration><![CDATA[private static long CountryBegin = 16776960L;]]></declaration>
<documentation>
</documentation>
</field>
<field name="CountryCode">
<declaration><![CDATA[private static readonly string[] CountryCode = new string[]]]></declaration>
<documentation>
</documentation>
</field>
<field name="CountryName">
<declaration><![CDATA[private static readonly string[] CountryName = new string[]]]></declaration>
<documentation>
</documentation>
</field>
<field name="m_MemoryStream">
<declaration><![CDATA[public MemoryStream m_MemoryStream;]]></declaration>
<documentation>
</documentation>
</field>
</fields>
<properties>
</properties>
<events>
</events>
</class>
</namespace>
</root>