コード例 #1
0
        private static void InitCountryEnum(ref IDictionary <string, GeoCountry> allCountryNamesDict)
        {
            var _d = new Dictionary <GeoCountry, string>(240)
            {
                { GeoCountry.None, "None" },
                { GeoCountry.Afghanistan, "Afghanistan" },
                { GeoCountry.Albania, "Albania" },
                { GeoCountry.Algeria, "Algeria" },
                { GeoCountry.American_Samoa, "American Samoa" },
                { GeoCountry.Andorra, "Andorra" },
                { GeoCountry.Angola, "Angola" },
                { GeoCountry.Anguilla, "Anguilla" },
                { GeoCountry.Antarctica, "Antarctica" },
                { GeoCountry.Antigua_and_Barbuda, "Antigua and Barbuda" },
                { GeoCountry.Argentina, "Argentina" },
                { GeoCountry.Armenia, "Armenia" },
                { GeoCountry.Aruba, "Aruba" },
                { GeoCountry.Australia, "Australia" },
                { GeoCountry.Austria, "Austria" },
                { GeoCountry.Azerbaijan, "Azerbaijan" },
                { GeoCountry.Bahamas, "Bahamas" },
                { GeoCountry.Bahrain, "Bahrain" },
                { GeoCountry.Bangladesh, "Bangladesh" },
                { GeoCountry.Barbados, "Barbados" },
                { GeoCountry.Belarus, "Belarus" },
                { GeoCountry.Belgium, "Belgium" },
                { GeoCountry.Belize, "Belize" },
                { GeoCountry.Benin, "Benin" },
                { GeoCountry.Bermuda, "Bermuda" },
                { GeoCountry.Bhutan, "Bhutan" },
                { GeoCountry.Bolivia, "Bolivia" },
                { GeoCountry.Bosnia_and_Herzegovina, "Bosnia and Herzegovina" },
                { GeoCountry.Botswana, "Botswana" },
                { GeoCountry.Bouvet_Island, "Bouvet Island" },
                { GeoCountry.Brazil, "Brazil" },
                { GeoCountry.British_Indian_Ocean_Territory, "British Indian Ocean Territory" },
                { GeoCountry.Brunei_Darussalam, "Brunei Darussalam" },
                { GeoCountry.Bulgaria, "Bulgaria" },
                { GeoCountry.Burkina_Faso, "Burkina Faso" },
                { GeoCountry.Burundi, "Burundi" },
                { GeoCountry.Cambodia, "Cambodia" },
                { GeoCountry.Cameroon, "Cameroon" },
                { GeoCountry.Canada, "Canada" },
                { GeoCountry.Cape_Verde, "Cape Verde" },
                { GeoCountry.Cayman_Islands, "Cayman Islands" },
                { GeoCountry.Central_African_Republic, "Central African Republic" },
                { GeoCountry.Chad, "Chad" },
                { GeoCountry.Chile, "Chile" },
                { GeoCountry.China, "China" },
                { GeoCountry.Christmas_Island, "Christmas Island" },
                { GeoCountry.Cocos_Keeling_Islands, "Cocos (Keeling Islands)" },
                { GeoCountry.Colombia, "Colombia" },
                { GeoCountry.Comoros, "Comoros" },
                { GeoCountry.Congo, "Congo" },
                { GeoCountry.Cook_Islands, "Cook Islands" },
                { GeoCountry.Costa_Rica, "Costa Rica" },
                { GeoCountry.Cote_DIvoire_Ivory_Coast, "Cote D'Ivoire (Ivory Coast)" },
                { GeoCountry.Croatia_Hrvatska, "Croatia (Hrvatska)" },
                { GeoCountry.Cuba, "Cuba" },
                { GeoCountry.Cyprus, "Cyprus" },
                { GeoCountry.Czech_Republic, "Czech Republic" },
                { GeoCountry.Denmark, "Denmark" },
                { GeoCountry.Djibouti, "Djibouti" },
                { GeoCountry.Dominica, "Dominica" },
                { GeoCountry.Dominican_Republic, "Dominican Republic" },
                { GeoCountry.East_Timor, "East Timor" },
                { GeoCountry.Ecuador, "Ecuador" },
                { GeoCountry.Egypt, "Egypt" },
                { GeoCountry.El_Salvador, "El Salvador" },
                { GeoCountry.Equatorial_Guinea, "Equatorial Guinea" },
                { GeoCountry.Eritrea, "Eritrea" },
                { GeoCountry.Estonia, "Estonia" },
                { GeoCountry.Ethiopia, "Ethiopia" },
                { GeoCountry.Falkland_Islands_Malvinas, "Falkland Islands (Malvinas)" },
                { GeoCountry.Faroe_Islands, "Faroe Islands" },
                { GeoCountry.Fiji, "Fiji" },
                { GeoCountry.Finland, "Finland" },
                { GeoCountry.France, "France" },
                { GeoCountry.France_Metropolitan, "France, Metropolitan" },
                { GeoCountry.French_Guiana, "French Guiana" },
                { GeoCountry.French_Polynesia, "French Polynesia" },
                { GeoCountry.French_Southern_Territories, "French Southern Territories" },
                { GeoCountry.Gabon, "Gabon" },
                { GeoCountry.Gambia, "Gambia" },
                { GeoCountry.Georgia, "Georgia" },
                { GeoCountry.Germany, "Germany" },
                { GeoCountry.Ghana, "Ghana" },
                { GeoCountry.Gibraltar, "Gibraltar" },
                { GeoCountry.Greece, "Greece" },
                { GeoCountry.Greenland, "Greenland" },
                { GeoCountry.Grenada, "Grenada" },
                { GeoCountry.Guadeloupe, "Guadeloupe" },
                { GeoCountry.Guam, "Guam" },
                { GeoCountry.Guatemala, "Guatemala" },
                { GeoCountry.Guinea, "Guinea" },
                { GeoCountry.GuineaBissau, "Guinea-Bissau" },
                { GeoCountry.Guyana, "Guyana" },
                { GeoCountry.Haiti, "Haiti" },
                { GeoCountry.Heard_and_McDonald_Islands, "Heard and McDonald Islands" },
                { GeoCountry.Honduras, "Honduras" },
                { GeoCountry.Hong_Kong, "Hong Kong" },
                { GeoCountry.Hungary, "Hungary" },
                { GeoCountry.Iceland, "Iceland" },
                { GeoCountry.India, "India" },
                { GeoCountry.Indonesia, "Indonesia" },
                { GeoCountry.Iran, "Iran" },
                { GeoCountry.Iraq, "Iraq" },
                { GeoCountry.Ireland, "Ireland" },
                { GeoCountry.Israel, "Israel" },
                { GeoCountry.Italy, "Italy" },
                { GeoCountry.Jamaica, "Jamaica" },
                { GeoCountry.Japan, "Japan" },
                { GeoCountry.Jordan, "Jordan" },
                { GeoCountry.Kazakhstan, "Kazakhstan" },
                { GeoCountry.Kenya, "Kenya" },
                { GeoCountry.Kiribati, "Kiribati" },
                { GeoCountry.Kuwait, "Kuwait" },
                { GeoCountry.Kyrgyzstan, "Kyrgyzstan" },
                { GeoCountry.Laos, "Laos" },
                { GeoCountry.Latvia, "Latvia" },
                { GeoCountry.Lebanon, "Lebanon" },
                { GeoCountry.Lesotho, "Lesotho" },
                { GeoCountry.Liberia, "Liberia" },
                { GeoCountry.Libya, "Libya" },
                { GeoCountry.Liechtenstein, "Liechtenstein" },
                { GeoCountry.Lithuania, "Lithuania" },
                { GeoCountry.Luxembourg, "Luxembourg" },
                { GeoCountry.Macau, "Macau" },
                { GeoCountry.Macedonia, "Macedonia" },
                { GeoCountry.Madagascar, "Madagascar" },
                { GeoCountry.Malawi, "Malawi" },
                { GeoCountry.Malaysia, "Malaysia" },
                { GeoCountry.Maldives, "Maldives" },
                { GeoCountry.Mali, "Mali" },
                { GeoCountry.Malta, "Malta" },
                { GeoCountry.Marshall_Islands, "Marshall Islands" },
                { GeoCountry.Martinique, "Martinique" },
                { GeoCountry.Mauritania, "Mauritania" },
                { GeoCountry.Mauritius, "Mauritius" },
                { GeoCountry.Mayotte, "Mayotte" },
                { GeoCountry.Mexico, "Mexico" },
                { GeoCountry.Micronesia, "Micronesia" },
                { GeoCountry.Moldova, "Moldova" },
                { GeoCountry.Monaco, "Monaco" },
                { GeoCountry.Mongolia, "Mongolia" },
                { GeoCountry.Montserrat, "Montserrat" },
                { GeoCountry.Morocco, "Morocco" },
                { GeoCountry.Mozambique, "Mozambique" },
                { GeoCountry.Myanmar, "Myanmar" },
                { GeoCountry.Namibia, "Namibia" },
                { GeoCountry.Nauru, "Nauru" },
                { GeoCountry.Nepal, "Nepal" },
                { GeoCountry.Netherlands, "Netherlands" },
                { GeoCountry.Netherlands_Antilles, "Netherlands Antilles" },
                { GeoCountry.New_Caledonia, "New Caledonia" },
                { GeoCountry.New_Zealand, "New Zealand" },
                { GeoCountry.Nicaragua, "Nicaragua" },
                { GeoCountry.Niger, "Niger" },
                { GeoCountry.Nigeria, "Nigeria" },
                { GeoCountry.Niue, "Niue" },
                { GeoCountry.Norfolk_Island, "Norfolk Island" },
                { GeoCountry.North_Korea, "North Korea" },
                { GeoCountry.Northern_Mariana_Islands, "Northern Mariana Islands" },
                { GeoCountry.Norway, "Norway" },
                { GeoCountry.Oman, "Oman" },
                { GeoCountry.Pakistan, "Pakistan" },
                { GeoCountry.Palau, "Palau" },
                { GeoCountry.Panama, "Panama" },
                { GeoCountry.Papua_New_Guinea, "Papua New Guinea" },
                { GeoCountry.Paraguay, "Paraguay" },
                { GeoCountry.Peru, "Peru" },
                { GeoCountry.Philippines, "Philippines" },
                { GeoCountry.Pitcairn, "Pitcairn" },
                { GeoCountry.Poland, "Poland" },
                { GeoCountry.Portugal, "Portugal" },
                { GeoCountry.Puerto_Rico, "Puerto Rico" },
                { GeoCountry.Qatar, "Qatar" },
                { GeoCountry.Reunion, "Reunion" },
                { GeoCountry.Romania, "Romania" },
                { GeoCountry.Russian_Federation, "Russian Federation" },
                { GeoCountry.Rwanda, "Rwanda" },
                { GeoCountry.S_Georgia_and_S_Sandwich_Isls, "S. Georgia and S. Sandwich Isls." },
                { GeoCountry.Saint_Kitts_and_Nevis, "Saint Kitts and Nevis" },
                { GeoCountry.Saint_Lucia, "Saint Lucia" },
                { GeoCountry.Saint_Vincent_and_The_Grenadines, "Saint Vincent and The Grenadines" },
                { GeoCountry.Samoa, "Samoa" },
                { GeoCountry.San_Marino, "San Marino" },
                { GeoCountry.Sao_Tome_and_Principe, "Sao Tome and Principe" },
                { GeoCountry.Saudi_Arabia, "Saudi Arabia" },
                { GeoCountry.Senegal, "Senegal" },
                { GeoCountry.Seychelles, "Seychelles" },
                { GeoCountry.Sierra_Leone, "Sierra Leone" },
                { GeoCountry.Singapore, "Singapore" },
                { GeoCountry.Slovak_Republic, "Slovak Republic" },
                { GeoCountry.Slovenia, "Slovenia" },
                { GeoCountry.Solomon_Islands, "Solomon Islands" },
                { GeoCountry.Somalia, "Somalia" },
                { GeoCountry.Sourth_Korea, "Sourth Korea" },
                { GeoCountry.South_Africa, "South Africa" },
                { GeoCountry.Spain, "Spain" },
                { GeoCountry.Sri_Lanka, "Sri Lanka" },
                { GeoCountry.St_Helena, "St. Helena" },
                { GeoCountry.St_Pierre_and_Miquelon, "St. Pierre and Miquelon" },
                { GeoCountry.Sudan, "Sudan" },
                { GeoCountry.Suriname, "Suriname" },
                { GeoCountry.Svalbard_and_Jan_Mayen_Islands, "Svalbard and Jan Mayen Islands" },
                { GeoCountry.Swaziland, "Swaziland" },
                { GeoCountry.Sweden, "Sweden" },
                { GeoCountry.Switzerland, "Switzerland" },
                { GeoCountry.Syria, "Syria" },
                { GeoCountry.Taiwan, "Taiwan" },
                { GeoCountry.Tajikistan, "Tajikistan" },
                { GeoCountry.Tanzania, "Tanzania" },
                { GeoCountry.Thailand, "Thailand" },
                { GeoCountry.Togo, "Togo" },
                { GeoCountry.Tokelau, "Tokelau" },
                { GeoCountry.Tonga, "Tonga" },
                { GeoCountry.Trinidad_and_Tobago, "Trinidad and Tobago" },
                { GeoCountry.Tunisia, "Tunisia" },
                { GeoCountry.Turkey, "Turkey" },
                { GeoCountry.Turkmenistan, "Turkmenistan" },
                { GeoCountry.Turks_and_Caicos_Islands, "Turks and Caicos Islands" },
                { GeoCountry.Tuvalu, "Tuvalu" },
                { GeoCountry.Uganda, "Uganda" },
                { GeoCountry.Ukraine, "Ukraine" },
                { GeoCountry.United_Arab_Emirates, "United Arab Emirates" },
                { GeoCountry.United_Kingdom, "United Kingdom" },
                { GeoCountry.United_States, "United States" },
                { GeoCountry.Uruguay, "Uruguay" },
                { GeoCountry.US_Minor_Outlying_Islands, "US Minor Outlying Islands" },
                { GeoCountry.Uzbekistan, "Uzbekistan" },
                { GeoCountry.Vanuatu, "Vanuatu" },
                { GeoCountry.Vatican_City_State_Holy_See, "Vatican City State (Holy See)" },
                { GeoCountry.Venezuela, "Venezuela" },
                { GeoCountry.Viet_Nam, "Viet Nam" },
                { GeoCountry.Virgin_Islands_British, "Virgin Islands (British)" },
                { GeoCountry.Virgin_Islands_US, "Virgin Islands (US)" },
                { GeoCountry.Wallis_and_Futuna_Islands, "Wallis and Futuna Islands" },
                { GeoCountry.Western_Sahara, "Western Sahara" },
                { GeoCountry.Yemen, "Yemen" },
                { GeoCountry.Yugoslavia, "Yugoslavia" },
                { GeoCountry.Zaire, "Zaire" },
                { GeoCountry.Zambia, "Zambia" },
                { GeoCountry.Zimbabwe, "Zimbabwe" }
            };

            XEnum <GeoCountry> .SetNames(_d);

            XEnum <GeoCountry> .CaseInsensitive = true;

            // ---

            var alld = allCountryNamesDict;

            foreach (var kv in XEnum <GeoCountry> .ValuesDict)
            {
                int        intVal = kv.Key;
                string     flNm   = kv.Value;
                GeoCountry gcVal  = (GeoCountry)intVal;
                string     enumNm = gcVal.ToString();
                string     enumNm_NoUnderscores = enumNm.Replace("_", "");

                if (gcVal == GeoCountry.None)
                {
                    continue;
                }

                // Add full country name
                if (!alld.ContainsKey(flNm))
                {
                    alld.Add(flNm, gcVal);
                }

                // Add raw enum country name (underscores)
                if (enumNm != flNm && !alld.ContainsKey(enumNm))
                {
                    alld.Add(enumNm, gcVal);
                }

                // Add enum country name removed underscores
                if (enumNm_NoUnderscores != enumNm && !alld.ContainsKey(enumNm_NoUnderscores))
                {
                    alld.Add(enumNm_NoUnderscores, gcVal);
                }
            }

            // Add abbreviations

            foreach (var kv in GeoCountriesByAbbreviationDict)
            {
                string     abbr = kv.Key;
                string     fnm  = kv.Value;
                GeoCountry val  = XEnum <GeoCountry> .Value(fnm);

                if (!alld.ContainsKey(abbr))
                {
                    alld.Add(abbr, val);
                }
            }
        }
コード例 #2
0
        private static void InitUSCanadaStateEnum(ref IDictionary <string, USCanadaState> allStateNamesDict)
        {
            // auto-generated
            var _d = new Dictionary <USCanadaState, string>(65)
            {
                { USCanadaState.None, "None" },
                { USCanadaState.Alabama, "Alabama" },
                { USCanadaState.Alaska, "Alaska" },
                { USCanadaState.Alberta, "Alberta" },
                { USCanadaState.Arizona, "Arizona" },
                { USCanadaState.Arkansas, "Arkansas" },
                { USCanadaState.British_Columbia, "British Columbia" },
                { USCanadaState.California, "California" },
                { USCanadaState.Colorado, "Colorado" },
                { USCanadaState.Connecticut, "Connecticut" },
                { USCanadaState.Delaware, "Delaware" },
                { USCanadaState.Florida, "Florida" },
                { USCanadaState.Georgia, "Georgia" },
                { USCanadaState.Hawaii, "Hawaii" },
                { USCanadaState.Idaho, "Idaho" },
                { USCanadaState.Illinois, "Illinois" },
                { USCanadaState.Indiana, "Indiana" },
                { USCanadaState.Iowa, "Iowa" },
                { USCanadaState.Kansas, "Kansas" },
                { USCanadaState.Kentucky, "Kentucky" },
                { USCanadaState.Louisiana, "Louisiana" },
                { USCanadaState.Maine, "Maine" },
                { USCanadaState.Manitoba, "Manitoba" },
                { USCanadaState.Maryland, "Maryland" },
                { USCanadaState.Massachusetts, "Massachusetts" },
                { USCanadaState.Michigan, "Michigan" },
                { USCanadaState.Minnesota, "Minnesota" },
                { USCanadaState.Mississippi, "Mississippi" },
                { USCanadaState.Missouri, "Missouri" },
                { USCanadaState.Montana, "Montana" },
                { USCanadaState.Nebraska, "Nebraska" },
                { USCanadaState.Nevada, "Nevada" },
                { USCanadaState.New_Brunswick, "New Brunswick" },
                { USCanadaState.New_Hampshire, "New Hampshire" },
                { USCanadaState.New_Jersey, "New Jersey" },
                { USCanadaState.New_Mexico, "New Mexico" },
                { USCanadaState.New_York, "New York" },
                { USCanadaState.Newfoundland, "Newfoundland" },
                { USCanadaState.North_Carolina, "North Carolina" },
                { USCanadaState.North_Dakota, "North Dakota" },
                { USCanadaState.Northwest_Territories, "Northwest Territories" },
                { USCanadaState.Nova_Scotia, "Nova Scotia" },
                { USCanadaState.Nunavut, "Nunavut" },
                { USCanadaState.Ohio, "Ohio" },
                { USCanadaState.Oklahoma, "Oklahoma" },
                { USCanadaState.Ontario, "Ontario" },
                { USCanadaState.Oregon, "Oregon" },
                { USCanadaState.Pennsylvania, "Pennsylvania" },
                { USCanadaState.Prince_Edward_Island, "Prince Edward Island" },
                { USCanadaState.Quebec, "Quebec" },
                { USCanadaState.Rhode_Island, "Rhode Island" },
                { USCanadaState.Saskatchewan, "Saskatchewan" },
                { USCanadaState.South_Carolina, "South Carolina" },
                { USCanadaState.South_Dakota, "South Dakota" },
                { USCanadaState.Tennessee, "Tennessee" },
                { USCanadaState.Texas, "Texas" },
                { USCanadaState.Utah, "Utah" },
                { USCanadaState.Vermont, "Vermont" },
                { USCanadaState.Virginia, "Virginia" },
                { USCanadaState.Washington, "Washington" },
                { USCanadaState.Washington_DC, "Washington DC" },
                { USCanadaState.West_Virginia, "West Virginia" },
                { USCanadaState.Wisconsin, "Wisconsin" },
                { USCanadaState.Wyoming, "Wyoming" },
                { USCanadaState.Yukon, "Yukon" }
            };

            XEnum <USCanadaState> .SetNames(_d);

            XEnum <USCanadaState> .CaseInsensitive = true;

            // ---

            var alld = allStateNamesDict;

            foreach (var kv in XEnum <USCanadaState> .ValuesDict)
            {
                int           intVal = kv.Key;
                string        flNm   = kv.Value;
                USCanadaState gcVal  = (USCanadaState)intVal;
                string        enumNm = gcVal.ToString();
                string        enumNm_NoUnderscores = enumNm.Replace("_", "");

                if (gcVal == USCanadaState.None)
                {
                    continue;
                }

                // Add full country name
                if (!alld.ContainsKey(flNm))
                {
                    alld.Add(flNm, gcVal);
                }

                // Add raw enum country name (underscores)
                if (enumNm != flNm && !alld.ContainsKey(enumNm))
                {
                    alld.Add(enumNm, gcVal);
                }

                // Add enum country name removed underscores
                if (enumNm_NoUnderscores != enumNm && !alld.ContainsKey(enumNm_NoUnderscores))
                {
                    alld.Add(enumNm_NoUnderscores, gcVal);
                }
            }

            // Add abbreviations

            foreach (var kv in USCanadaStatesByAbbreviationDict)
            {
                string        abbr = kv.Key;
                string        fnm  = kv.Value;
                USCanadaState val  = XEnum <USCanadaState> .Value(fnm);

                if (!alld.ContainsKey(abbr))
                {
                    alld.Add(abbr, val);
                }
            }
        }