Example #1
0
        T Map(Dictionary <string, List <string> > data)
        {
            var hit = new T();

            foreach (var p in _listProperties.GetProperties())
            {
                List <string> newValues = FindField(p.Name, data);

                if (newValues == null)
                {
                    continue;
                }

                if (p.PropertyType == typeof(List <string>))
                {
                    p.SetValue(hit, newValues, null);
                }

                else if (p.PropertyType == typeof(List <int?>))
                {
                    p.SetValue(hit, _convertArray.StringToIntNull(newValues), null);
                }

                else if (p.PropertyType == typeof(List <int>))
                {
                    p.SetValue(hit, _convertArray.StringToInt(newValues), null);
                }

                else if (p.PropertyType == typeof(List <DateTime>))
                {
                    p.SetValue(hit, _convertArray.StringToDate(newValues), null);
                }


                else if (p.PropertyType == typeof(string))
                {
                    p.SetValue(hit, newValues.FirstOrDefault(), null);
                }

                else if (p.PropertyType == typeof(int?))
                {
                    p.SetValue(hit, _convertArray.StringToIntNull(newValues).FirstOrDefault(), null);
                }

                else if (p.PropertyType == typeof(int))
                {
                    p.SetValue(hit, _convertArray.StringToInt(newValues).FirstOrDefault(), null);
                }

                else if (p.PropertyType == typeof(DateTime))
                {
                    p.SetValue(hit, _convertArray.StringToDate(newValues).FirstOrDefault(), null);
                }
            }

            return(hit);
        }