Esempio n. 1
0
        public static List <Property> GetProperties(BankMapping mappings, Type type)
        {
            var lst                    = new List <Property>();
            var properties             = type.GetProperties();
            var dico                   = mappings.MappingFields.ToDictionary(x => x.Out, x => new { x.In, x.Format });
            var numberGroupSeparator   = !string.IsNullOrWhiteSpace(mappings.NumberGroupSeparator) ? mappings.NumberGroupSeparator : NumberGroupSeparator.Value;
            var numberDecimalSeparator = !string.IsNullOrWhiteSpace(mappings.NumberDecimalSeparator) ? mappings.NumberDecimalSeparator : NumberDecimalSeparator.Value;


            for (int i = 0; i < properties.Length; i++)
            {
                var source = properties[i].GetCustomAttributes(typeof(DescriptionAttribute), false) as DescriptionAttribute[];
                var desc   = properties[i].GetCustomAttributes(typeof(DisplayNameAttribute), false) as DisplayNameAttribute[];

                lst.Add(new Property(
                            properties[i].Name,
                            source.Length > 0 && dico.ContainsKey(source[0].Description) ? dico[source[0].Description].In : "UNMAPPED",
                            desc.Length > 0 ? desc[0].DisplayName : properties[i].Name,
                            Type.GetTypeCode(properties[i].PropertyType),
                            properties[i],
                            numberGroupSeparator,
                            numberDecimalSeparator,
                            source.Length > 0 && dico.ContainsKey(source[0].Description) ? dico[source[0].Description].Format : null
                            ));
            }
            return(lst);
        }
Esempio n. 2
0
 public static List <Property> GetProperties <T>(BankMapping mappings)
 {
     return(GetProperties(mappings, typeof(T)));
 }