| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Reflection;
- namespace CarLocalMeter
- {
- public class ReflexCls
- {
- /// <summary>
- ///
- /// </summary>
- /// <param name="objs"></param>
- /// <param name="iType">0 Id查询 1非Id查询</param>
- /// <param name="strId">iType是0的时候strId则有值</param>
- /// <returns></returns>
- public static Dictionary<string, object> method(object[] objs, out int iType, out string strId)
- {
- iType = 1;
- strId = "";
- object value;
- Dictionary<string, object> dt = new Dictionary<string, object>();
- 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;
- }
- }
- }
|