示例#1
0
        public static TType GetObject <TType>(string row)
        {
            var rowData = RowParser.Parse(row);



            var resObj = Activator.CreateInstance <TType>();

            foreach (var prop in typeof(TType).GetProperties())
            {
                var mkField = MemberNameHelper.PascalToTrain(prop.Name);
                if (!rowData.ContainsKey(mkField))
                {
                    continue;
                }

                var fieldVal = rowData[mkField];

                var propType = prop.PropertyType;

                var propVal = Convert.ChangeType(fieldVal, propType);
                prop.SetValue(resObj, propVal);
            }
            return(resObj);
        }
示例#2
0
        public static IEnumerable <string> GetMkPropList <TType>()
        {
            var lst = new List <string>();

            foreach (var prop in typeof(TType).GetProperties())
            {
                lst.Add(MemberNameHelper.PascalToTrain(prop.Name));
            }
            ;
            return(lst);
        }