شركة التطبيقات المتكاملة لتصميم النظم البرمجية الخاصة

Integrated Applications Programming Company

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