| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Reflection;
- using System.Text;
- using System.Threading.Tasks;
- namespace RailLocalMeter
- {
- public class EntityBase<T>
- {
- public M format<M>(T t, M m, List<string> list = null)
- {
- PropertyInfo[] PropertyInfos1 = t.GetType().GetProperties();
- PropertyInfo[] PropertyInfos2 = m.GetType().GetProperties();
- object value;
- foreach (PropertyInfo p2 in PropertyInfos2)
- {
- foreach (PropertyInfo p1 in PropertyInfos1)
- {
- if (list != null)
- {
- bool noChange = list.Contains(p2.Name);
- if (noChange)
- {
- break;
- }
- }
- if (p2.Name == "createManName" || p2.Name == "createManNo" || p2.Name == "createTime" || p2.Name == "updateManName" || p2.Name == "updateManNo" || p2.Name == "updateTime" || p2.Name == "valueFlag")
- {
- break;
- }
- if (p2.Name.ToUpper() == p1.Name.ToUpper())
- {
- value = p1.GetValue(t, null);
- if (value != null)
- {
- p2.SetValue(m, value, null);
- }
- }
- }
- }
- return m;
- }
- }
- }
|