示例#1
0
    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);
    }
示例#2
0
 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
         );
 }