public static T ToModel <T>(DataRow dr) where T : new() { if (dr == null) { U_Debug.LogErrorStr("转Model时传入了空行"); return(new T()); } T t = new T(); PropertyInfo[] propertys = t.GetType().GetProperties(); Type type = typeof(T); string tempName = ""; foreach (PropertyInfo pi in propertys) { tempName = pi.Name; if (dr.Table.Columns.Contains(tempName)) { if (!pi.CanWrite) { continue; } object value = dr[tempName]; if (value != DBNull.Value) { pi.SetValue(t, Convert.ChangeType(value, pi.PropertyType, CultureInfo.CurrentCulture), null); } } } return(t); }
public static void DebugEquip(EquipM equip) { U_Debug.LogStr( equip.id + " " + equip.goId + " " + equip.name + " " + equip.tag + " " + equip.layer + " " + equip.isStatic + " " + equip.isHoverOutline + " " + equip.isClickFlashing + " " + equip.oriPos + " " + equip.oriLocalPos ); }