Professional Applications Programmers/Consultants برمجة واستشارات تطبيقات الإنترنت
Skip Navigation LinksHome » Code Library » Country

Public general use code classes and xml files that we've compiled and used over the years:

Country geographic coordinates and standard UN naming conventions.

   1:  using System;
   2:  using System.Web;
   3:  using System.Xml;
   4:  using System.Xml.XPath;
   5:  using System.Xml.Xsl;
   6:  using System.Configuration;
   7:  using System.IO;
   8:  using System.Text;
   9:  using System.Collections;
  10:  using System.Collections.Generic;
  11:  using System.Text.RegularExpressions;
  12:  using System.Linq;
  13:  using System.Xml.Linq;
  14:  using System.Reflection;
  15:  using System.Globalization;
  16:   
  17:  namespace Ia.Cl.Model
  18:  {
  19:      ////////////////////////////////////////////////////////////////////////////
  20:   
  21:      /// <summary publish="true">
  22:      /// Country geographic coordinates and standard UN naming conventions.
  23:      /// </summary>
  24:      /// <remarks> 
  25:      /// Copyright © 2001-2015 Jasem Y. Al-Shamlan (info@ia.com.kw), Internet Applications - Kuwait. All Rights Reserved.
  26:      ///
  27:      /// This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
  28:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  29:      ///
  30:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  31:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  32:      /// 
  33:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  34:      /// 
  35:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  36:      /// </remarks> 
  37:      public class Country
  38:      {
  39:          private static Hashtable fipsToIso2Hashtable, iso2ToFipsHashtable;
  40:          private static XDocument xd;
  41:   
  42:          // # FIPS 10-4 to ISO 3166-1 country codes
  43:          // # Created by OpenGeoCode.Org, Submitted into the Public Domain June 4, 2014 (Version 5)
  44:          // #
  45:          // # Last FIPS 10-4 Revision, as Published by CIA World Factbook, Jan. 2014
  46:          // # Metadata
  47:          // # FIPS 10-4, 
  48:          // # ISO 3166-1 alpha-2, 
  49:          // # ISO 3166-1 alpha-3, 
  50:          // # ISO 3166-1 numeric-3,
  51:          // # Inclusive in Country 
  52:   
  53:          private static List<string> fipsIsoList = new List<string> {
  54:              "AF", "AF", "AFB", "004",
  55:              //"AX", "", "", "",
  56:              //"GB",
  57:              "AL", "AL", "ALB", "008",
  58:              "AG", "DZ", "DZA", "012",
  59:              "AQ", "AS", "ASM", "016",
  60:              "AN", "AD", "AND", "020",
  61:              "AO", "AO", "AGO", "024",
  62:              "AV", "AI", "AIA", "660",
  63:              "AY", "AQ", "ATA", "010",
  64:              "AC", "AG", "ATG", "028",
  65:              "AR", "AR", "ARG", "032",
  66:              "AM", "AM", "ARM", "051",
  67:              "AA", "AW", "ABW", "533",
  68:              //"AT", "", "", "", "AU",
  69:              "AS", "AU", "AUS", "036",
  70:              "AU", "AT", "AUT", "040",
  71:              "AJ", "AZ", "AZE", "031",
  72:              "BF", "BS", "BHS", "044",
  73:              "BA", "BH", "BHR", "048",
  74:              //"FQ", "", "", "", "UM",
  75:              "BG", "BD", "BGD", "050",
  76:              "BB", "BB", "BRB", "052",
  77:              //"BS", "", "", "", "FR",
  78:              "BO", "BY", "BLR", "112",
  79:              "BE", "BE", "BEL", "056",
  80:              "BH", "BZ", "BLZ", "084",
  81:              "BN", "BJ", "BEN", "204",
  82:              "BD", "BM", "BMU", "060",
  83:              "BT", "BT", "BTN", "064",
  84:              "BL", "BO", "BOL", "068",
  85:              "BK", "BA", "BIH", "070",
  86:              "BC", "BW", "BWA", "072",
  87:              "BV", "BV", "BVT", "074",
  88:              "BR", "BR", "BRA", "076",
  89:              "IO", "IO", "IOT", "086",
  90:              "VI", "VG", "VGB", "092",
  91:              "BX", "BN", "BRN", "096",
  92:              "BU", "BG", "BGR", "100",
  93:              "UV", "BF", "BFA", "854",
  94:              "BM", "MM", "MMR", "104",
  95:              "BY", "BI", "BDI", "108",
  96:              "CV", "CV", "CPV", "132",
  97:              "CB", "KH", "KHM", "116",
  98:              "CM", "CM", "CMR", "120",
  99:              "CA", "CA", "CAN", "124",
 100:              "CJ", "KY", "CYM", "136",
 101:              "CT", "CF", "CAF", "140",
 102:              "CD", "TD", "TCD", "148",
 103:              "CI", "CL", "CHL", "152",
 104:              "CH", "CN", "CHN", "156",
 105:              "KT", "CX", "CXR", "162",
 106:              //"IP", "", "", "", "FR",
 107:              "CK", "CC", "CCK", "166",
 108:              "CO", "CO", "COL", "170",
 109:              "CN", "KM", "COM", "174",
 110:              "CG", "CD", "COD", "180",
 111:              "CF", "CG", "COG", "178",
 112:              "CW", "CK", "COK", "184",
 113:              //"CR", "", "", "", "AU",
 114:              "CS", "CR", "CRI", "188",
 115:              "IV", "CI", "CIV", "384",
 116:              "HR", "HR", "HRV", "191",
 117:              "CU", "CU", "CUB", "192",
 118:              "UC", "CW", "CUW", "531",
 119:              "CY", "CY", "CYP", "196",
 120:              "EZ", "CZ", "CZE", "203",
 121:              "DA", "DK", "DNK", "208",
 122:              //"DX", "", "", "", "GB",
 123:              "DJ", "DJ", "DJI", "262",
 124:              "DO", "DM", "DMA", "212",
 125:              "DR", "DO", "DOM", "214",
 126:              "EC", "EC", "ECU", "218",
 127:              "EG", "EG", "EGY", "818",
 128:              "ES", "SV", "SLV", "222",
 129:              "EK", "GQ", "GNQ", "226",
 130:              "ER", "ER", "ERI", "232",
 131:              "EN", "EE", "EST", "233",
 132:              "ET", "ET", "ETH", "231",
 133:              //"EU", "", "", "", "FR",
 134:              "FK", "FK", "FLK", "238",
 135:              "FO", "FO", "FRO", "234",
 136:              "FJ", "FJ", "FJI", "242",
 137:              "FI", "FI", "FIN", "246",
 138:              "FR", "FR", "FRA", "250",
 139:              //"", "FX", "FXX", "249",
 140:              "FG", "GF", "GUF", "254",
 141:              "FP", "PF", "PYF", "258",
 142:              "FS", "TF", "ATF", "260",
 143:              "GB", "GA", "GAB", "266",
 144:              "GA", "GM", "GMB", "270",
 145:              "GZ", "PS", "PSE", "275",
 146:              "GG", "GE", "GEO", "268",
 147:              "GM", "DE", "DEU", "276",
 148:              "GH", "GH", "GHA", "288",
 149:              "GI", "GI", "GIB", "292",
 150:              //"GO", "", "", "", "FR",
 151:              "GR", "GR", "GRC", "300",
 152:              "GL", "GL", "GRL", "304",
 153:              "GJ", "GD", "GRD", "308",
 154:              "GP", "GP", "GLP", "312",
 155:              "GQ", "GU", "GUM", "316",
 156:              "GT", "GT", "GTM", "320",
 157:              "GK", "GG", "GGY", "831",
 158:              "GV", "GN", "GIN", "324",
 159:              "PU", "GW", "GNB", "624",
 160:              "GY", "GY", "GUY", "328",
 161:              "HA", "HT", "HTI", "332",
 162:              "HM", "HM", "HMD", "334",
 163:              "VT", "VA", "VAT", "336",
 164:              "HO", "HN", "HND", "340",
 165:              "HK", "HK", "HKG", "344",
 166:              //"HQ", "", "", "", "UM",
 167:              "HU", "HU", "HUN", "348",
 168:              "IC", "IS", "ISL", "352",
 169:              "IN", "IN", "IND", "356",
 170:              "ID", "ID", "IDN", "360",
 171:              "IR", "IR", "IRN", "364",
 172:              "IZ", "IQ", "IRQ", "368",
 173:              "EI", "IE", "IRL", "372",
 174:              "IM", "IM", "IMN", "833",
 175:              "IS", "IL", "ISR", "376",
 176:              "IT", "IT", "ITA", "380",
 177:              "JM", "JM", "JAM", "388",
 178:              //"JN", "", "", "", "SV",
 179:              "JA", "JP", "JPN", "392",
 180:              //"DQ", "", "", "", "UM",
 181:              "JE", "JE", "JEY", "832",
 182:              //"JQ", "", "", "", "UM",
 183:              "JO", "JO", "JOR", "400",
 184:              //"JU", "", "", "", "FR",
 185:              "KZ", "KZ", "KAZ", "398",
 186:              "KE", "KE", "KEN", "404",
 187:              //"KQ", "", "", "", "UM",
 188:              "KR", "KI", "KIR", "296",
 189:              "KN", "KP", "PRK", "408",
 190:              "KS", "KR", "KOR", "410",
 191:              //"KV", "XK", "XKS", "",
 192:              "KU", "KW", "KWT", "414",
 193:              "KG", "KG", "KGZ", "417",
 194:              "LA", "LA", "LAO", "418",
 195:              "LG", "LV", "LVA", "428",
 196:              "LE", "LB", "LBN", "422",
 197:              "LT", "LS", "LSO", "426",
 198:              "LI", "LR", "LBR", "430",
 199:              "LY", "LY", "LBY", "434",
 200:              "LS", "LI", "LIE", "438",
 201:              "LH", "LT", "LTU", "440",
 202:              "LU", "LU", "LUX", "442",
 203:              "MC", "MO", "MAC", "446",
 204:              "MK", "MK", "MKD", "807",
 205:              "MA", "MG", "MDG", "450",
 206:              "MI", "MW", "MWI", "454",
 207:              "MY", "MY", "MYS", "458",
 208:              "MV", "MV", "MDV", "462",
 209:              "ML", "ML", "MKI", "466",
 210:              "MT", "MT", "MLT", "470",
 211:              "RM", "MH", "MHL", "584",
 212:              "MB", "MQ", "MTQ", "474",
 213:              "MR", "MR", "MRT", "478",
 214:              "MP", "MU", "MUS", "480",
 215:              "MF", "YT", "MYT", "175",
 216:              "MX", "MX", "MEX", "484",
 217:              "FM", "FM", "FSM", "583",
 218:              //"MQ", "", "", "", "UM",
 219:              "MD", "MD", "MDA", "498",
 220:              "MN", "MC", "MCO", "492",
 221:              "MG", "MN", "MNG", "496",
 222:              "MJ", "ME", "MNE", "499",
 223:              "MH", "MS", "MSR", "500",
 224:              "MO", "MA", "MAR", "504",
 225:              "MZ", "MZ", "MOZ", "508",
 226:              "WA", "NA", "NAM", "516",
 227:              "NR", "NR", "NRU", "520",
 228:              //"BQ", "", "", "", "UM",
 229:              "NP", "NP", "NPL", "524",
 230:              "NL", "NL", "NLT", "528",
 231:              //"NT", "", "", "",
 232:              "NC", "NC", "NCL", "540",
 233:              "NZ", "NZ", "NZL", "554",
 234:              "NU", "NI", "NIC", "558",
 235:              "NG", "NE", "NER", "562",
 236:              "NI", "NG", "NGA", "566",
 237:              "NE", "NU", "NIU", "570",
 238:              "NF", "NF", "NFK", "574",
 239:              "CQ", "MP", "MNP", "580",
 240:              "NO", "NO", "NOR", "578",
 241:              "MU", "OM", "OMN", "512",
 242:              "PK", "PK", "PAK", "586",
 243:              "PS", "PW", "PLW", "585",
 244:              //"LQ", "", "", "", "UM",
 245:              "PM", "PA", "PAN", "591",
 246:              "PP", "PG", "PNG", "592",
 247:              //"PF", "", "", "",
 248:              "PA", "PY", "PRY", "600",
 249:              "PE", "PE", "PER", "604",
 250:              "RP", "PH", "PHL", "608",
 251:              "PC", "PN", "PCN", "612",
 252:              "PL", "PL", "POL", "616",
 253:              "PO", "PT", "PRT", "620",
 254:              "RQ", "PR", "PRI", "630",
 255:              "QA", "QA", "QAT", "634",
 256:              "RE", "RE", "REU", "638",
 257:              "RO", "RO", "ROU", "642",
 258:              "RS", "RU", "RUS", "643",
 259:              "RW", "RW", "RWA", "646",
 260:              "TB", "BL", "BLM", "652",
 261:              "SH", "SH", "SHN", "654",
 262:              "SC", "KN", "KNA", "659",
 263:              "ST", "LC", "LCA", "662",
 264:              "RN", "MF", "MAF", "663",
 265:              "SB", "PM", "SPM", "666",
 266:              "VC", "VC", "VCT", "670",
 267:              "WS", "WS", "WSM", "882",
 268:              "SM", "SM", "SMR", "674",
 269:              "TP", "ST", "STP", "678",
 270:              "SA", "SA", "SAU", "682",
 271:              "SG", "SN", "SEN", "686",
 272:              "RI", "RS", "SRB", "688",
 273:              "SE", "SC", "SYC", "690",
 274:              "SL", "SL", "SLE", "694",
 275:              "SN", "SG", "SGP", "702",
 276:              "NN", "SX", "SXM", "534",
 277:              "LO", "SK", "SVK", "703",
 278:              "SI", "SI", "SVN", "705",
 279:              "BP", "SB", "SLB", "090",
 280:              "SO", "SO", "SOM", "706",
 281:              "SF", "ZA", "ZAF", "710",
 282:              "SX", "GS", "SGS", "239",
 283:              "OD", "SS", "SSD", "728",
 284:              "SP", "ES", "ESP", "724",
 285:              //"PG", "", "", "",
 286:              "CE", "LK", "LKA", "144",
 287:              "SU", "SD", "SDN", "729",
 288:              "NS", "SR", "SUR", "740",
 289:              "SV", "SJ", "SJM", "744",
 290:              "WZ", "SZ", "SWZ", "748",
 291:              "SW", "SE", "SWE", "752",
 292:              "SZ", "CH", "CHE", "756",
 293:              "SY", "SY", "SYR", "760",
 294:              "TW", "TW", "TWN", "158",
 295:              "TI", "TJ", "TJK", "762",
 296:              "TZ", "TZ", "TZA", "834",
 297:              "TH", "TH", "THA", "764",
 298:              "TT", "TL", "TLS", "626",
 299:              "TO", "TG", "TGO", "768",
 300:              "TL", "TK", "TKL", "772",
 301:              "TN", "TO", "TON", "776",
 302:              "TD", "TT", "TTO", "780",
 303:              //"TE", "", "", "", "FR",
 304:              "TS", "TN", "TUN", "788",
 305:              "TU", "TR", "TUR", "792",
 306:              "TX", "TM", "TKM", "795",
 307:              "TK", "TC", "TCA", "796",
 308:              "TV", "TV", "TUV", "798",
 309:              "UG", "UG", "UGA", "800",
 310:              "UP", "UA", "UKR", "804",
 311:              "AE", "AE", "ARE", "784",
 312:              "UK", "GB", "GBR", "826",
 313:              "US", "US", "USA", "840",
 314:              //"", "UM", "UMI", "581",
 315:              "UY", "UY", "URY", "858",
 316:              "UZ", "UZ", "UZB", "860",
 317:              "NH", "VU", "VUT", "548",
 318:              "VE", "VE", "VEN", "862",
 319:              "VM", "VN", "VNH", "704",
 320:              "VQ", "VI", "VIR", "850",
 321:              //"WQ", "", "", "", "UM",
 322:              "WF", "WF", "WLF", "876",
 323:              "WE", "PS", "PSE", "275",
 324:              "WI", "EH", "ESH", "732",
 325:              "YM", "YE", "YEM", "887",
 326:              "ZA", "ZM", "ZMB", "894",
 327:              "ZI", "ZW", "ZWE", "716" };
 328:   
 329:          private static List<Country> countryList;
 330:   
 331:          /// <summary/>
 332:          /// [Key]
 333:          public int Itu { get; set; }
 334:          /// <summary/>
 335:          public string Name { get; set; }
 336:          /// <summary/>
 337:          public string ArabicName { get; set; }
 338:          /// <summary/>
 339:          public string NativeName { get; set; }
 340:          /// <summary/>
 341:          public Dictionary<string, string> NameDictionary { get; set; }
 342:          /// <summary/>
 343:          public string Latitude { get; set; }
 344:          /// <summary/>
 345:          public string Longitude { get; set; }
 346:          /// <summary/>
 347:          public string Capital { get; set; }
 348:          /// <summary/>
 349:          public string CapitalLatitude { get; set; }
 350:          /// <summary/>
 351:          public string CapitalLongitude { get; set; }
 352:          /// <summary/>
 353:          public string Iso2 { get; set; }
 354:          /// <summary/>
 355:          public string Iso3 { get; set; }
 356:          /// <summary/>
 357:          public string Iana { get; set; }
 358:          /// <summary/>
 359:          public string Un { get; set; }
 360:          /// <summary/>
 361:          public string Ioc { get; set; }
 362:          /// <summary/>
 363:          public string Fips { get; set; }
 364:          /// <summary/>
 365:          public string SpokenLanguageIso6391ListString { get; set; }
 366:   
 367:   
 368:          ////////////////////////////////////////////////////////////////////////////
 369:   
 370:          /// <summary>
 371:          /// 
 372:          /// </summary>
 373:          public Country() { }
 374:   
 375:          ////////////////////////////////////////////////////////////////////////////
 376:   
 377:          /// <summary>
 378:          ///
 379:          /// </summary>
 380:          public static List<Country> List
 381:          {
 382:              get
 383:              {
 384:                  if (countryList == null || countryList.Count == 0)
 385:                  {
 386:                      countryList = (from c in XDocument.Elements("countryList").Elements("country")
 387:                                     where c.Attribute("itu").Value != "" && c.Attribute("iso2").Value != "" && Iso2ToFipsHashtable.ContainsKey(c.Attribute("iso2").Value)
 388:                                     select new Country
 389:                                     {
 390:                                         Itu = int.Parse(c.Attribute("itu").Value.Replace("-", "")),
 391:                                         Name = global::Ia.Cl.Model.Default.ToTitleCase(c.Attribute("name").Value),
 392:                                         ArabicName = c.Attribute("arabicName").Value,
 393:                                         NativeName = c.Attribute("nativeName").Value,
 394:                                         NameDictionary = _NameDictionary(c),
 395:                                         Latitude = c.Attribute("latitude").Value,
 396:                                         Longitude = c.Attribute("longitude").Value,
 397:                                         Capital = c.Attribute("capital").Value,
 398:                                         CapitalLatitude = c.Attribute("capitalLatitude").Value,
 399:                                         CapitalLongitude = c.Attribute("capitalLongitude").Value,
 400:                                         Iso2 = c.Attribute("iso2").Value,
 401:                                         Iso3 = c.Attribute("iso3").Value,
 402:                                         Iana = c.Attribute("iana").Value,
 403:                                         Un = c.Attribute("un").Value,
 404:                                         Ioc = c.Attribute("ioc").Value,
 405:                                         Fips = Iso2ToFipsHashtable[c.Attribute("iso2").Value].ToString(),
 406:                                         SpokenLanguageIso6391ListString = c.Attribute("spokenLanguageIso6391List").Value
 407:                                     }
 408:                      ).ToList<Country>();
 409:                  }
 410:   
 411:                  return countryList;
 412:              }
 413:          }
 414:   
 415:          ////////////////////////////////////////////////////////////////////////////
 416:   
 417:          /// <summary>
 418:          /// 
 419:          /// </summary>
 420:          private static Dictionary<string, string> _NameDictionary(XElement xElement)
 421:          {
 422:              IEnumerable<XAttribute> xAttributeList;
 423:              Dictionary<string, string> dictionary;
 424:   
 425:              dictionary = new Dictionary<string, string>();
 426:   
 427:              // name="Japan" arabicName="" nativeName="日本" japaneseName="日本"
 428:   
 429:              if (xElement.HasAttributes)
 430:              {
 431:                  xAttributeList = xElement.Attributes();
 432:   
 433:                  foreach (XAttribute xa in xAttributeList)
 434:                  {
 435:                      switch (xa.Name.LocalName)
 436:                      {
 437:                          case "name": dictionary.Add("en", xa.Value); break;
 438:                          case "arabicName": dictionary.Add("ar", xa.Value); break;
 439:                          case "spanishName": dictionary.Add("es", xa.Value); break;
 440:                          case "frenchName": dictionary.Add("fr", xa.Value); break;
 441:                          case "germanName": dictionary.Add("de", xa.Value); break;
 442:                          case "dutchName": dictionary.Add("nl", xa.Value); break;
 443:                          case "russianName": dictionary.Add("ru", xa.Value); break;
 444:   
 445:                          case "chineseTraditionalName": dictionary.Add("zh_traditional", xa.Value); break;
 446:                          case "chineseSimplifiedName": dictionary.Add("zh_simplified", xa.Value); break;
 447:   
 448:                          case "japaneseName": dictionary.Add("ja", xa.Value); break;
 449:                          case "koreanName": dictionary.Add("ko", xa.Value); break;
 450:                          case "catalanName": dictionary.Add("ca", xa.Value); break;
 451:                          case "portugueseName": dictionary.Add("pt", xa.Value); break;
 452:                          case "italianName": dictionary.Add("it", xa.Value); break;
 453:                          case "danishName": dictionary.Add("da", xa.Value); break;
 454:                          case "faroeseName": dictionary.Add("fo", xa.Value); break;
 455:   
 456:                          case "hindiName": dictionary.Add("hi", xa.Value); break;
 457:                          case "bengaliName": dictionary.Add("bn", xa.Value); break;
 458:                          case "gujaratiName": dictionary.Add("gu", xa.Value); break;
 459:                          case "kashmiriName": dictionary.Add("ks", xa.Value); break;
 460:                          case "malayalamName": dictionary.Add("ml", xa.Value); break;
 461:                          case "marathiName": dictionary.Add("mr", xa.Value); break;
 462:                          case "oriyaName": dictionary.Add("or", xa.Value); break;
 463:                          case "punjabiName": dictionary.Add("pa", xa.Value); break;
 464:                          case "tamilName": dictionary.Add("ta", xa.Value); break;
 465:                          case "teluguName": dictionary.Add("te", xa.Value); break;
 466:                          case "urduName": dictionary.Add("ur", xa.Value); break;
 467:                          case "kannadaName": dictionary.Add("kn", xa.Value); break;
 468:                          case "assameseName": dictionary.Add("as", xa.Value); break;
 469:                          case "sanskritName": dictionary.Add("sa", xa.Value); break;
 470:                          case "sindhiName": dictionary.Add("sd", xa.Value); break;
 471:   
 472:                          case "armenianName": dictionary.Add("hy", xa.Value); break;
 473:                          case "persianName": dictionary.Add("fa", xa.Value); break;
 474:   
 475:                          case "pushtoName": dictionary.Add("ps", xa.Value); break;
 476:                          case "kirghizName": dictionary.Add("ky", xa.Value); break;
 477:                          case "turkmenName": dictionary.Add("tk", xa.Value); break;
 478:                          case "khmerName": dictionary.Add("km", xa.Value); break;
 479:   
 480:                          case "somaliName": dictionary.Add("so", xa.Value); break;
 481:                          case "afarName": dictionary.Add("aa", xa.Value); break;
 482:   
 483:                          case "icelandicName": dictionary.Add("is", xa.Value); break;
 484:                          case "swedishName": dictionary.Add("sv", xa.Value); break;
 485:                          case "norwegianName": dictionary.Add("no", xa.Value); break;
 486:                          case "kazakhName": dictionary.Add("kk", xa.Value); break;
 487:   
 488:                          case "laoName": dictionary.Add("lo", xa.Value); break;
 489:   
 490:                          case "afrikaansName": dictionary.Add("af", xa.Value); break;
 491:                          case "swahiliName": dictionary.Add("sw", xa.Value); break;
 492:   
 493:                          case "albanianName": dictionary.Add("sq", xa.Value); break;
 494:                          case "greekName": dictionary.Add("el", xa.Value); break;
 495:   
 496:                          case "indonesianName": dictionary.Add("id", xa.Value); break;
 497:                          case "latvianName": dictionary.Add("lv", xa.Value); break;
 498:                          case "lithuanianName": dictionary.Add("lt", xa.Value); break;
 499:   
 500:                          case "macedonianName": dictionary.Add("mk", xa.Value); break;
 501:                          case "turkishName": dictionary.Add("tr", xa.Value); break;
 502:                          case "serbianName": dictionary.Add("sr", xa.Value); break;
 503:   
 504:                          case "nauruanName": dictionary.Add("na", xa.Value); break;
 505:   
 506:                          case "filipinoName": dictionary.Add("tl", xa.Value); break;
 507:   
 508:                          case "romanianName": dictionary.Add("ro", xa.Value); break;
 509:                          case "hungarianName": dictionary.Add("hu", xa.Value); break;
 510:   
 511:                          case "tajikName": dictionary.Add("tg", xa.Value); break;
 512:   
 513:                          case "ukrainianName": dictionary.Add("uk", xa.Value); break;
 514:                          case "polishName": dictionary.Add("pl", xa.Value); break;
 515:   
 516:                          case "ShonaNam": dictionary.Add("sn", xa.Value); break;
 517:                          case "NorthNdebeleName": dictionary.Add("nd", xa.Value); break;
 518:                          case "SouthNdebeleName": dictionary.Add("nr", xa.Value); break;
 519:   
 520:                          case "fijianName": dictionary.Add("fj", xa.Value); break;
 521:                          case "kurdishName": dictionary.Add("ku", xa.Value); break;
 522:   
 523:                          case "zuluName": dictionary.Add("zu", xa.Value); break;
 524:                          case "xhosaName": dictionary.Add("xh", xa.Value); break;
 525:                          case "malagasyName": dictionary.Add("mg", xa.Value); break;
 526:   
 527:                          case "nepaliName": dictionary.Add("ne", xa.Value); break;
 528:   
 529:                          case "hebrewName": dictionary.Add("he", xa.Value); break;
 530:   
 531:                          case "vietnameseName": dictionary.Add("vi", xa.Value); break;
 532:   
 533:                          default: break;
 534:                      }
 535:                  }
 536:              }
 537:   
 538:              return dictionary;
 539:          }
 540:   
 541:          ////////////////////////////////////////////////////////////////////////////
 542:   
 543:          /// <summary>
 544:          ///
 545:          /// </summary>
 546:          public static List<Country> List2
 547:          {
 548:              // used for special cases
 549:              get
 550:              {
 551:                  int i;
 552:   
 553:                  if (countryList == null || countryList.Count == 0)
 554:                  {
 555:                      countryList = (from q in XDocument.Elements("countryList").Elements("country")
 556:                                     select new Country
 557:                                     {
 558:                                         Itu = int.TryParse(q.Attribute("itu").Value.Replace("-", ""), out i) ? i : 0,
 559:                                         Name = global::Ia.Cl.Model.Default.ToTitleCase(q.Attribute("name").Value),
 560:                                         ArabicName = q.Attribute("arabicName").Value,
 561:                                         NativeName = q.Attribute("nativeName").Value,
 562:                                         Latitude = q.Attribute("latitude").Value,
 563:                                         Longitude = q.Attribute("longitude").Value,
 564:                                         Capital = q.Attribute("capital").Value,
 565:                                         CapitalLatitude = q.Attribute("capitalLatitude").Value,
 566:                                         CapitalLongitude = q.Attribute("capitalLongitude").Value,
 567:                                         Iso2 = q.Attribute("iso2").Value,
 568:                                         Iso3 = q.Attribute("iso3").Value,
 569:                                         Iana = q.Attribute("iana").Value,
 570:                                         Un = q.Attribute("un").Value,
 571:                                         Ioc = q.Attribute("ioc").Value,
 572:                                         Fips = (q.Attribute("iso2").Value != "" && Iso2ToFipsHashtable.ContainsKey(q.Attribute("iso2").Value)) ? Iso2ToFipsHashtable[q.Attribute("iso2").Value].ToString() : "",
 573:                                         SpokenLanguageIso6391ListString = q.Attribute("spokenLanguageIso6391List").Value
 574:                                     }
 575:                      ).ToList<Country>();
 576:                  }
 577:   
 578:                  return countryList;
 579:              }
 580:          }
 581:   
 582:          ////////////////////////////////////////////////////////////////////////////
 583:   
 584:          /// <summary>
 585:          ///
 586:          /// </summary>
 587:          public static Hashtable FipsToIso2Hashtable
 588:          {
 589:              get
 590:              {
 591:                  if (fipsToIso2Hashtable == null || fipsToIso2Hashtable.Count == 0)
 592:                  {
 593:                      fipsToIso2Hashtable = new Hashtable(fipsIsoList.Count / 4);
 594:   
 595:                      for (int i = 0; i < fipsIsoList.Count; i += 4)
 596:                      {
 597:                          fipsToIso2Hashtable[fipsIsoList[i]] = fipsIsoList[i + 1];
 598:                      }
 599:                  }
 600:   
 601:                  return fipsToIso2Hashtable;
 602:              }
 603:          }
 604:   
 605:          ////////////////////////////////////////////////////////////////////////////
 606:   
 607:          /// <summary>
 608:          ///
 609:          /// </summary>
 610:          public static Hashtable Iso2ToFipsHashtable
 611:          {
 612:              get
 613:              {
 614:                  if (iso2ToFipsHashtable == null || iso2ToFipsHashtable.Count == 0)
 615:                  {
 616:                      iso2ToFipsHashtable = new Hashtable(fipsIsoList.Count / 4);
 617:   
 618:                      for (int i = 0; i < fipsIsoList.Count; i += 4)
 619:                      {
 620:                          iso2ToFipsHashtable[fipsIsoList[i + 1]] = fipsIsoList[i];
 621:                      }
 622:                  }
 623:   
 624:                  return iso2ToFipsHashtable;
 625:              }
 626:          }
 627:   
 628:          ////////////////////////////////////////////////////////////////////////////
 629:   
 630:          /// <summary>
 631:          ///
 632:          /// </summary>
 633:          public static string FipsFromIso2(string iso2)
 634:          {
 635:              string fips;
 636:   
 637:              if (Iso2ToFipsHashtable.ContainsKey(iso2)) fips = Iso2ToFipsHashtable[iso2].ToString();
 638:              else fips = null;
 639:   
 640:              return fips;
 641:          }
 642:   
 643:          ////////////////////////////////////////////////////////////////////////////
 644:   
 645:          /// <summary>
 646:          ///
 647:          /// </summary>
 648:          public static string Iso2FromFips(string fips)
 649:          {
 650:              string iso2;
 651:   
 652:              if (FipsToIso2Hashtable.ContainsKey(fips)) iso2 = FipsToIso2Hashtable[fips].ToString();
 653:              else iso2 = null;
 654:   
 655:              return iso2;
 656:          }
 657:   
 658:          ////////////////////////////////////////////////////////////////////////////
 659:   
 660:          /// <summary>
 661:          ///
 662:          /// </summary>
 663:          public List<global::Ia.Cl.Model.Language> SpokenLanguageList
 664:          {
 665:              get
 666:              {
 667:                  string s;
 668:                  List<global::Ia.Cl.Model.Language> list;
 669:   
 670:                  if (!string.IsNullOrEmpty(SpokenLanguageIso6391ListString))
 671:                  {
 672:                      s = "," + SpokenLanguageIso6391ListString;
 673:   
 674:                      list = (from l in global::Ia.Cl.Model.Language.List where s.Contains("," + l.Iso6391) select l).ToList();
 675:                  }
 676:                  else list = null;
 677:   
 678:                  return list;
 679:              }
 680:          }
 681:   
 682:          ////////////////////////////////////////////////////////////////////////////
 683:   
 684:          /// <summary>
 685:          /// 
 686:          /// How to embed and access resources by using Visual C# http://support.microsoft.com/kb/319292/en-us
 687:          /// 
 688:          /// 1. Change the "Build Action" property of your XML file from "Content" to "Embedded Resource".
 689:          /// 2. Add "using System.Reflection".
 690:          /// 3. See sample below.
 691:          /// 
 692:          /// </summary>
 693:   
 694:          private static XDocument XDocument
 695:          {
 696:              get
 697:              {
 698:                  Assembly _assembly;
 699:                  StreamReader streamReader;
 700:   
 701:                  xd = null;
 702:                  _assembly = Assembly.GetExecutingAssembly();
 703:                  streamReader = new StreamReader(_assembly.GetManifestResourceStream("Ia.Cl.model.country.country.xml"));
 704:   
 705:                  try
 706:                  {
 707:                      if (streamReader.Peek() != -1)
 708:                      {
 709:                          xd = System.Xml.Linq.XDocument.Load(streamReader);
 710:                      }
 711:                  }
 712:                  catch (Exception)
 713:                  {
 714:                  }
 715:                  finally
 716:                  {
 717:                  }
 718:   
 719:                  return xd;
 720:              }
 721:          }
 722:   
 723:          ////////////////////////////////////////////////////////////////////////////
 724:          ////////////////////////////////////////////////////////////////////////////
 725:      }
 726:  }