private NumberFormatPattern GetCurrencyStyleFormat(CurrencySignFormat sign) { XElement currencyFormats = elements.FirstOrDefault(v => v.Name.LocalName == "currencyFormats"); if (currencyFormats == null) { return(this.Parent.GetCurrencyStyleFormat(sign)); } if (CldrUtility.IsAlias(currencyFormats, out string numberSystem)) { return(GetFormat(locale, numberSystem).GetCurrencyStyleFormat(sign)); } XElement currencyFormat = currencyFormats.XPathSelectElement(String.Format("currencyFormatLength[not(@type)]/currencyFormat[@type = '{0}']", IntlProviderOptions.ToStringValue(sign))); if (currencyFormat == null) { return(this.Parent.GetCurrencyStyleFormat(sign)); } return(ParseNumberFormatPattern(currencyFormat.Value)); }
public ReadOnlyDictionary <PluralCategories, NumberFormatPattern> GetCurrencyStyleFormat(string code, CurrencyDisplayFormat format, CurrencySignFormat sign) { Dictionary <PluralCategories, NumberFormatPattern> dict = new Dictionary <PluralCategories, NumberFormatPattern>(); NumberFormatPattern pattern = GetCurrencyStyleFormat(sign); FormattedString[] src = new[] { pattern.PositivePattern, pattern.NegativePattern, pattern.ZeroPattern }; FormattedString[] dst = new FormattedString[3]; foreach (KeyValuePair <PluralCategories, string> e in GetCurrencyName(code, format)) { Array.Clear(dst, 0, 3); for (int i = 0; i < 3; i++) { if (src[i] != dst[0]) { FormattedPart[] parts = src[i].GetParts(); int index = Array.FindIndex(parts, v => v.Type == FormattedPartType.Currency); parts[index] = new FormattedPart(FormattedPartType.Currency, e.Value); dst[i] = new FormattedString(parts); } } dict.Add(e.Key, new NumberFormatPattern(dst[0], dst[1] ?? dst[0], dst[2] ?? dst[0])); } return(new ReadOnlyDictionary <PluralCategories, NumberFormatPattern>(dict)); }