using System; using System.Collections.Generic; using System.Linq; using System.Reflection; namespace CarLocalMeter { public class ReflexCls { /// /// /// /// /// 0 Id查询 1非Id查询 /// iType是0的时候strId则有值 /// public static Dictionary method(object[] objs, out int iType, out string strId) { iType = 1; strId = ""; object value; Dictionary dt = new Dictionary(); foreach (object obj in objs) { Type tp = obj.GetType(); if (tp.IsClass) { PropertyInfo[] PropertyInfos1 = obj.GetType().GetProperties(); foreach (PropertyInfo p1 in PropertyInfos1) { value = p1.GetValue(obj, null); if (value != null) { dt.Add(p1.Name, value); } } } } if (dt != null) { if (dt.Where(s => s.Key == "pageNum").Count() == 0) { dt.Add("pageNum", 1); } if (dt.Where(s => s.Key == "pageSize").Count() == 0) { dt.Add("pageSize", 999999); } } return dt; } } }