本文整理汇总了C#中System.Globalization.RegionInfo类的典型用法代码示例。如果您正苦于以下问题:C# RegionInfo类的具体用法?C# RegionInfo怎么用?C# RegionInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RegionInfo类属于System.Globalization命名空间,在下文中一共展示了RegionInfo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: DotNETFrameworkFallback
/// <summary>
/// Dots the net framework fallback.
/// </summary>
/// <param name="storeAlias">The store alias.</param>
/// <returns></returns>
protected virtual List<Country> DotNETFrameworkFallback(string storeAlias)
{
Store store = StoreHelper.GetByAlias(storeAlias);
CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;
CultureInfo currentUICulture = Thread.CurrentThread.CurrentUICulture;
if (store != null)
{
Thread.CurrentThread.CurrentCulture = store.CultureInfo;
Thread.CurrentThread.CurrentUICulture = store.CultureInfo;
}
var cultureList = new Dictionary<string, string>();
foreach (var culture in CultureInfo.GetCultures(CultureTypes.SpecificCultures))
{
var region = new RegionInfo(culture.LCID);
if (!(cultureList.ContainsKey(region.TwoLetterISORegionName)))
cultureList.Add(region.TwoLetterISORegionName, region.DisplayName);
}
List<Country> countries = cultureList.Select(culture => new Country {Name = culture.Value, Code = culture.Key}).Where(country => !string.IsNullOrEmpty(country.Name)).OrderBy(country => country.Name).ToList();
if (store != null)
{
Thread.CurrentThread.CurrentCulture = currentCulture;
Thread.CurrentThread.CurrentUICulture = currentUICulture;
}
return countries;
}
开发者ID:Chuhukon,项目名称:uWebshop-Releases,代码行数:38,代码来源:UwebshopApplicationCachedCountriesRepository.cs
示例2: RegisterCultureBasedOn
public static RegistrationResults RegisterCultureBasedOn(string newCultureCode, string languageCode, string regionCode)
{
var baseCulture = new CultureInfo(languageCode);
var baseRegionInfo = new RegionInfo(regionCode);
return RegisterCultureBasedOn(newCultureCode, baseCulture, baseRegionInfo);
}
开发者ID:lindorff,项目名称:CustomCulturesRegistrator,代码行数:7,代码来源:CultureInfoTreater.cs
示例3: GetCurrencyInfo
/// <summary>
/// Gets the currency information.
/// </summary>
/// <param name="isoCurrency">The iso currency.</param>
/// <returns>The currency</returns>
/// <exception cref="System.ArgumentException"></exception>
public static Currency GetCurrencyInfo(string isoCurrency)
{
var r = GetRegionFromCache(isoCurrency);
if (r == null)
{
foreach (var c in CultureInfo.GetCultures(CultureTypes.SpecificCultures))
{
var reg = new RegionInfo(c.LCID);
if (String.Compare(isoCurrency, reg.ISOCurrencySymbol, StringComparison.OrdinalIgnoreCase) == 0)
{
var currency = new Currency
{
CurrencyEnglishName = reg.CurrencyEnglishName,
CurrencyNativeName = reg.CurrencyNativeName,
CurrencySymbol = reg.CurrencySymbol,
IsoCurrencySymbol = reg.ISOCurrencySymbol
};
SaveRegionInCache(isoCurrency, currency);
return currency;
}
}
throw new ArgumentException();
}
return r;
}
开发者ID:yonglehou,项目名称:saas-ecom,代码行数:34,代码来源:CurrencyHelper.cs
示例4: RegisterCustomCulture
private static void RegisterCustomCulture(string customCultureName, string parentCultureName)
{
Console.WriteLine("Registering {0}", customCultureName);
try
{
CultureAndRegionInfoBuilder cib =
new CultureAndRegionInfoBuilder(customCultureName, CultureAndRegionModifiers.None);
CultureInfo ci = new CultureInfo(parentCultureName);
cib.LoadDataFromCultureInfo(ci);
RegionInfo ri = new RegionInfo(parentCultureName);
cib.LoadDataFromRegionInfo(ri);
cib.Register();
Console.WriteLine("Success.");
}
catch (InvalidOperationException)
{
// This is OK, means that this is already registered.
Console.WriteLine("The custom culture {0} was already registered", customCultureName);
}
catch (Exception ex)
{
Console.WriteLine("Registering the custom culture {0} failed", customCultureName);
Console.WriteLine(ex);
}
Console.WriteLine();
}
开发者ID:gmilazzoitag,项目名称:OpenLiveWriter,代码行数:28,代码来源:Program.cs
示例5: PopulateCurrencies
private void PopulateCurrencies()
{
List<ListItem> items = new List<ListItem>();
foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.SpecificCultures))
{
if (ci.IsNeutralCulture != true)
{
RegionInfo region = new RegionInfo(ci.LCID);
string currencyName = region.CurrencyEnglishName;
string currencySymbol = region.CurrencySymbol;
string format = string.Format("{0} [{1}]", currencyName, currencySymbol);
ListItem item = new ListItem();
item.Text = format;
item.Value = format;
// Add to our list
if (!items.Contains(item))
items.Add(item);
}
}
// Sort array
items = items.OrderBy(li => li.Text).ToList();
// Add to our list
ddlCurrenciesSymbol.Items.AddRange(items.ToArray());
}
开发者ID:KnowMoreIT,项目名称:CloudPanel_3.0,代码行数:31,代码来源:settings.aspx.cs
示例6: CalculateShippingCost
public decimal CalculateShippingCost(float packageWeightInKilograms, Size<float> packageDimensionsInInches, RegionInfo destination)
{
Contract.Requires<ArgumentOutOfRangeException>(packageWeightInKilograms > 0f, "Package weight must be positive and non-zero");
Contract.Requires<ArgumentOutOfRangeException>(packageDimensionsInInches.X > 0f && packageDimensionsInInches.Y > 0f, "Package dimensions must be positive and non-zero");
return decimal.MinusOne;
}
开发者ID:aleksandrzak-rafal,项目名称:AdaptiveCode,代码行数:7,代码来源:ShippingStrategy.cs
示例7: PopulateCurrencies
/// <summary>
/// Populates the list of currencies
/// </summary>
private void PopulateCurrencies()
{
ddlCurrencySymbol.Items.Clear();
foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.SpecificCultures))
{
if (!ci.IsNeutralCulture)
{
RegionInfo region = new RegionInfo(ci.LCID);
ListItem item = new ListItem();
item.Value = region.CurrencySymbol;
item.Text = string.Format("{0} [{1}]", region.CurrencyNativeName, region.CurrencySymbol);
ddlCurrencySymbol.Items.Add(item);
}
}
// Select the current culture
RegionInfo currentRegion = new RegionInfo(CultureInfo.CurrentCulture.LCID);
if (currentRegion != null)
{
ListItem item = ddlCurrencySymbol.Items.FindByValue(currentRegion.CurrencySymbol);
if (item != null)
ddlCurrencySymbol.SelectedValue = item.Value;
}
}
开发者ID:blinds52,项目名称:CloudPanel,代码行数:30,代码来源:settings.aspx.cs
示例8: TestCreationOfBasicMoney
public void TestCreationOfBasicMoney()
{
var currentSymbol = CultureInfo.CurrentCulture.NumberFormat.CurrencySymbol;
var currentRegion = new RegionInfo(CultureInfo.CurrentCulture.LCID);
var currentCode = currentRegion.ISOCurrencySymbol;
var currentEnglishName = currentRegion.CurrencyEnglishName;
var currentDigits = CultureInfo.CurrentCulture.NumberFormat.CurrencyDecimalDigits;
//Locale specific formatting
var money1 = new Money(2000.1234567m, CurrencyCodes.USD);
Assert.AreEqual("$2,000.12", money1.ToString());
//Default currency
var money2 = new Money(3000m);
Assert.AreEqual(currentCode, money2.CurrencyCode);
Assert.AreEqual(currentSymbol, money2.CurrencySymbol);
Assert.AreEqual(currentEnglishName, money2.CurrencyName);
Assert.AreEqual(currentDigits, money2.DecimalDigits);
//Implicit casting of int, decimal and double to Money
var money3 = new Money(5.0d);
var money4 = new Money(5.0m);
var money5 = new Money(5);
Money money6 = 5.0d;
Money money7 = 5.0m;
Money money8 = 5;
Money money9 = 5.0f;
Money money10 = 5.0;
Assert.IsTrue(money3 == money4 && money4 == money5 && money5 == money6 && money6 == money7 && money7 == money8 && money8 == money9 && money9 == money10);
//Generic 3char currency code formatting instead of locale based with symbols
Assert.AreEqual("USD2,000", money1.ToString(true));
}
开发者ID:Padhraic,项目名称:Utile.Money,代码行数:34,代码来源:MoneyTest.cs
示例9: GetCountryList
public static IEnumerable<RegionInfo> GetCountryList()
{
//create a new Generic list to hold the country names returned
Dictionary<string, RegionInfo> regions = new Dictionary<string, RegionInfo>();
//create an array of CultureInfo to hold all the cultures found, these include the users local cluture, and all the
//cultures installed with the .Net Framework
CultureInfo[] cultures = CultureInfo.GetCultures(CultureTypes.SpecificCultures);
//loop through all the cultures found
foreach (CultureInfo culture in cultures)
{
//pass the current culture's Locale ID (http://msdn.microsoft.com/en-us/library/0h88fahh.aspx)
//to the RegionInfo contructor to gain access to the information for that culture
RegionInfo region = new RegionInfo(culture.LCID);
//make sure out generic list doesnt already
//contain this country
if (!(regions.ContainsKey(region.EnglishName)))
//not there so add the EnglishName (http://msdn.microsoft.com/en-us/library/system.globalization.regioninfo.englishname.aspx)
//value to our generic list
regions.Add(region.EnglishName, region);
}
return regions.Values;
}
开发者ID:Qupy,项目名称:Extensions,代码行数:25,代码来源:CountrySelectListDataSource.cs
示例10: FormatCurrency
public string FormatCurrency(decimal amount, Currency targetCurrency, bool includeSymbol = true)
{
//find out the culture for the target currency
var culture = CultureInfo.GetCultures(CultureTypes.SpecificCultures).FirstOrDefault(c =>
{
var r = new RegionInfo(c.LCID);
return string.Equals(r.ISOCurrencySymbol, targetCurrency.CurrencyCode, StringComparison.CurrentCultureIgnoreCase);
});
//the format of display
var format = targetCurrency.DisplayFormat;
var locale = targetCurrency.DisplayLocale;
if (culture == null)
{
if (!string.IsNullOrEmpty(locale))
{
culture = new CultureInfo(locale);
}
}
if (string.IsNullOrEmpty(format))
{
format = culture == null || !includeSymbol ? "{0:N}" : "{0:C}";
}
return culture == null ? string.Format(format, amount): string.Format(culture, format, amount);
}
开发者ID:Console-Byte,项目名称:mobsocial,代码行数:28,代码来源:FormatterService.cs
示例11: OnInit
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
_dlInstalledLanguages = new DropDownList();
foreach (var language in umbraco.cms.businesslogic.language.Language.GetAllAsList())
{
var culture = new CultureInfo(language.CultureAlias);
if (culture.IsNeutralCulture) continue;
var currencyRegion = new RegionInfo(culture.LCID);
var value = language.FriendlyName + " " + currencyRegion.ISOCurrencySymbol + " (" + currencyRegion.CurrencySymbol +
" - " +
currencyRegion.CurrencyEnglishName + ")";
_dlInstalledLanguages.Items.Add(new ListItem(value, language.id.ToString(CultureInfo.InvariantCulture)));
}
_dlInstalledLanguages.SelectedValue = _data.Value.ToString();
var user = User.GetCurrent();
if (!user.IsAdmin())
_dlInstalledLanguages.Enabled = false;
if (ContentTemplateContainer != null) ContentTemplateContainer.Controls.Add(_dlInstalledLanguages);
}
开发者ID:Chuhukon,项目名称:uWebshop-Releases,代码行数:27,代码来源:LanguagePickerDataEditor.cs
示例12: PosTest3
public void PosTest3()
{
CultureInfo myCultur = new CultureInfo("en-IE");
string culture = myCultur.Name;
RegionInfo myRegInfo = new RegionInfo(culture);
Assert.False(myRegInfo.Name != "en-IE" && myRegInfo.Name != "IE");
}
开发者ID:jmhardison,项目名称:corefx,代码行数:7,代码来源:RegionInfoCtor1.cs
示例13: CreateCulture
public CreateCultureResponse CreateCulture(CreateCultureRequest request)
{
var response = new CreateCultureResponse();
if (request.Data != null)
{
var culture = CultureInfo.GetCultureInfo(request.Data.Code);
var region = new RegionInfo(culture.LCID);
//locate associted info
var language = Uow.Languages.Get(o => o.Iso3.Equals(culture.ThreeLetterISOLanguageName), null, null).FirstOrDefault();
var country = Uow.Countries.Get(o => o.Iso3.Equals(region.ThreeLetterISORegionName), null, null).FirstOrDefault();
// insert culture
Uow.Cultures.Add(new Culture
{
Id = request.Data.Id,
ParentCultureId = request.Data.ParentCulture.Id,
Code = request.Data.Code,
Language = language ?? new Language { Id = culture.LCID, Iso2 = culture.TwoLetterISOLanguageName, Iso3 = culture.ThreeLetterISOLanguageName, Localizations = new Collection<LanguageLocalized> { new LanguageLocalized { LanguageId = culture.LCID, CultureId = CultureInfo.InvariantCulture.LCID, Name = culture.NativeName } } },
Country = country ?? new Country { Id = region.GeoId, Iso2 = region.TwoLetterISORegionName, Iso3 = region.ThreeLetterISORegionName, Localizations = new Collection<CountryLocalized> { new CountryLocalized { CountryId = region.GeoId, CultureId = CultureInfo.InvariantCulture.LCID, Name = region.NativeName } } },
_localizations = new List<CultureLocalized>
{
new CultureLocalized{ Id = request.Data.Id, CultureId = CultureInfo.InvariantCulture.LCID, Name = request.Data.Name}
},
});
Uow.Commit();
}
else
{
throw new Exception("Cannot create empty element");
}
return response;
}
开发者ID:hanoitown,项目名称:vnsf,代码行数:32,代码来源:GlobalizationSettings.cs
示例14: PosTest4
public void PosTest4()
{
CultureInfo myCultur = new CultureInfo("en-GB");
string culture = myCultur.Name;
RegionInfo myRegInfo = new RegionInfo(culture);
Assert.True(myRegInfo.Name == "en-GB" || myRegInfo.Name == "GB");
}
开发者ID:noahfalk,项目名称:corefx,代码行数:7,代码来源:RegionInfoCtor1.cs
示例15: VoucherDetails
public VoucherDetails(string strBarCode)
{
InitializeComponent();
this.BarCode = strBarCode;
txtSiteCode.IsReadOnly = true;
txtEffectiveDate.IsReadOnly = true;
txtExpiryDate.IsReadOnly = true;
txtBarCode.IsReadOnly = true;
txtVoucherType.IsReadOnly = true;
txtPrintedDevice.IsReadOnly = true;
txtRedeemDevice.IsReadOnly = true;
txtVoidDevice.IsReadOnly = true;
txtErrorDevice.IsReadOnly = true;
txtPrintedDate.IsReadOnly = true;
txtRedeemDate.IsReadOnly = true;
txtVoidDate.IsReadOnly = true;
txtAmount.IsReadOnly = true;
txtStatus.IsReadOnly = true;
txtErrorDescription.IsReadOnly = true;
txtIssuedUserName.IsReadOnly = true;
txtRedeemUser.IsReadOnly = true;
txtVoidUser.IsReadOnly = true;
txtRedeemSiteCode.IsReadOnly = true;
string CurrencySymbol = new RegionInfo(CurrentSiteCulture).CurrencySymbol;
lblAmount.Content=lblAmount.Content+" in "+CurrencySymbol+" :";
GetVoucherInformation();
}
开发者ID:sreenandini,项目名称:test_buildscripts,代码行数:27,代码来源:VoucherDetails.xaml.cs
示例16: PosTest1
public void PosTest1()
{
CultureInfo myCulture = new CultureInfo("en-US");
RegionInfo regionInfo = new RegionInfo(myCulture.Name);
string strCurrencySymbol = regionInfo.CurrencySymbol;
Assert.Equal("$", strCurrencySymbol);
}
开发者ID:jmhardison,项目名称:corefx,代码行数:7,代码来源:RegionInfoCurrencySymbol.cs
示例17: PromoPrint
private PromoPrint()
{
InitializeComponent();
try
{
txtPrinterName.Text = Settings.VoucherPrinterName.ToUpper();
IIssueTicket objCashDeskOperator = IssueTicketBusinessObject.CreateInstance();
string CurrencySymbol = new RegionInfo(CurrentSiteCulture).CurrencySymbol;
lblPromoTickAmt.Content = "Promotional Voucher Amount in " + CurrencySymbol + ":";
lblTotPromoTickVal.Content = "Total Promotional Voucher Value in " + CurrencySymbol + ":";
if (Settings.VoucherPrinterName.ToUpper() == "COUPONEXPRESS")
txtSerialNumber.Text = objCashDeskOperator.GetPrinterInformation();
else
lblSerialNumber.Visibility = Visibility.Collapsed;
txtPromoTickAmt.TextChanged += new TextChangedEventHandler(txtPromoTickAmt_TextChanged);
txtPromoTickAmt.AddHandler(TextBox.PreviewKeyDownEvent, new KeyEventHandler(txtPromoTickAmt_KeyDown), true);
var d = Convert.ToDecimal(1.1);
decimal.TryParse(d.ToString(new CultureInfo(ExtensionMethods.CurrentCurrenyCulture)), NumberStyles.Currency, new CultureInfo(ExtensionMethods.CurrentCurrenyCulture), out d);
sFormat = d.ToString(new CultureInfo(ExtensionMethods.CurrentCurrenyCulture)).Substring(1, 1);
}
catch (Exception ex)
{
ExceptionManager.Publish(ex);
}
}
开发者ID:sreenandini,项目名称:test_buildscripts,代码行数:32,代码来源:PromoPrint.xaml.cs
示例18: SlimTvFanartProvider
public SlimTvFanartProvider()
{
_settings = ServiceRegistration.Get<ISettingsManager>().Load<SlimTvLogoSettings>();
_dataFolder = ServiceRegistration.Get<IPathManager>().GetPath("<DATA>\\Logos\\");
var currentCulture = ServiceRegistration.Get<ILocalization>().CurrentCulture;
_country = new RegionInfo(currentCulture.LCID);
}
开发者ID:davinx,项目名称:MediaPortal-2,代码行数:7,代码来源:SlimTvFanartProvider.cs
示例19: FormatAmountWithCorrectCurrencySymbolWhenUsingCurrencySymbolConstructor
public void FormatAmountWithCorrectCurrencySymbolWhenUsingCurrencySymbolConstructor()
{
foreach (var cultureInfo in CultureInfo.GetCultures(CultureTypes.AllCultures))
{
// Arrange
if (cultureInfo.LCID.Equals(127) || cultureInfo.IsNeutralCulture)
{
continue;
}
var amount = 10.00M;
var regionInfo = new RegionInfo(cultureInfo.LCID);
var currencySymbol = regionInfo.CurrencySymbol;
var expected = string.Format(cultureInfo, "{0:C}", amount);
var money = new Money(amount, cultureInfo.Name);
// Act
var moneyAsString = money.ToStringWithCurrencySymbol();
Console.WriteLine($"Culture Name: {cultureInfo.Name}\t\tCurrency Symbol: {currencySymbol}\t\tToString: {moneyAsString}");
// Assert
Assert.That(moneyAsString.Equals(expected));
}
}
开发者ID:KaraokeStu,项目名称:LeadPipe.Net,代码行数:32,代码来源:ToStringWithCurrencySymbolShould.cs
示例20: PosTest2
public void PosTest2()
{
CultureInfo myCultur = new CultureInfo("zh-CN");
string culture = myCultur.Name;
RegionInfo myRegInfo = new RegionInfo(culture);
Assert.True(myRegInfo.Name == "zh-CN" || myRegInfo.Name == "CN");
}
开发者ID:noahfalk,项目名称:corefx,代码行数:7,代码来源:RegionInfoCtor1.cs
注:本文中的System.Globalization.RegionInfo类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论