private static string GetValue(IFieldDefinition fieldDefinition, decimal key, DecimalOption options, FieldFormatArgs args)
        {
            if (!fieldDefinition.IsMultiCulture)
            {
                return(key.ToString(args.Format, args.Culture ?? CultureInfo.InvariantCulture));
            }

            var option = options?.Items.FirstOrDefault(x => x.Value == key);

            if (option == null)
            {
                return(key.ToString(args.Format, args.Culture ?? CultureInfo.InvariantCulture));
            }

            string translation;

            if (option.Name.TryGetValue(args.Culture?.Name ?? CultureInfo.CurrentCulture.Name, out translation))
            {
                return(translation);
            }
            return(key.ToString(args.Format, args.Culture ?? CultureInfo.InvariantCulture));
        }
Ejemplo n.º 2
0
 public static IEnumerable <string> GetDecimalOptionValues(DecimalOption options, IList <decimal> values, CultureInfo cultureInfo)
 {
     return(values.Select(value => GetDecimalOptionValue(options, value, cultureInfo)));
 }
Ejemplo n.º 3
0
 public DecimalOption(DecimalOption option, decimal value) : base(option, value)
 {
 }
Ejemplo n.º 4
0
        public static string GetDecimalOptionValue(DecimalOption options, decimal value, CultureInfo cultureInfo)
        {
            var option = options?.Items?.FirstOrDefault(x => x.Value == value);

            return(option != null && option.Name.TryGetValue(cultureInfo.Name, out var translation) ? translation : value.ToString(cultureInfo));
        }