Exemple #1
0
        // 给属性赋值
        public static void _field_set_value(string value, FieldInfo fieldInfo, BaseCsv csv)
        {
            string fieldName = fieldInfo.FieldType.Name;

            switch (fieldName)
            {
            case "Int32":
                _internal_int_set_value(value, fieldInfo, csv);
                break;

            case "Int32[]":
                _internal_ints_set_value(value, fieldInfo, csv);
                break;

            case "String":
                _internal_string_set_value(value, fieldInfo, csv);
                break;

            case "String[]":
                _internal_strings_set_value(value, fieldInfo, csv);
                break;

            case "Boolean":
                _internal_bool_set_value(value, fieldInfo, csv);
                break;

            case "Boolean[]":
                _internal_bools_set_value(value, fieldInfo, csv);
                break;

            case "Single":
                _internal_float_set_value(value, fieldInfo, csv);
                break;

            case "Single[]":
                _internal_floats_set_value(value, fieldInfo, csv);
                break;

            default:
                Debug.LogError("csvloader找不到对应的类型:" + fieldName + "数值:" + value);
                break;
            }
        }
Exemple #2
0
        public static void _internal_bools_set_value(string value, FieldInfo fieldInfo, BaseCsv csv)
        {
            bool[] boolResult;

            if (!string.IsNullOrEmpty(value))
            {
                string[] strArr = value.Split(CVS_SPLIT);
                boolResult = new bool[strArr.Length];
                for (int i = 0; i < strArr.Length; i++)
                {
                    boolResult[i] = bool.Parse(strArr[i]);
                }
            }
            else
            {
                boolResult = new bool[0];
            }

            fieldInfo.SetValue(csv, boolResult);
        }
Exemple #3
0
 public static void _internal_bool_set_value(string value, FieldInfo fieldInfo, BaseCsv csv)
 {
     if (string.IsNullOrEmpty(value))
     {
         fieldInfo.SetValue(csv, false);
     }
     else
     {
         fieldInfo.SetValue(csv, value == "1");
     }
 }
Exemple #4
0
        public static void _internal_floats_set_value(string value, FieldInfo fieldInfo, BaseCsv csv)
        {
            float[] floatResult;

            if (!string.IsNullOrEmpty(value))
            {
                string[] strArr = value.Split(CVS_SPLIT);
                floatResult = new float[strArr.Length];
                for (int i = 0; i < strArr.Length; i++)
                {
                    floatResult[i] = float.Parse(strArr[i]);
                }
            }
            else
            {
                floatResult = new float[0];
            }

            fieldInfo.SetValue(csv, floatResult);
        }
Exemple #5
0
 public static void _internal_float_set_value(string value, FieldInfo fieldInfo, BaseCsv csv)
 {
     if (string.IsNullOrEmpty(value))
     {
         fieldInfo.SetValue(csv, 0);
     }
     else
     {
         fieldInfo.SetValue(csv, float.Parse(value));
     }
 }
Exemple #6
0
        public static void _internal_strings_set_value(string value, FieldInfo fieldInfo, BaseCsv csv)
        {
            string[] strResult;
            if (string.IsNullOrEmpty(value))
            {
                strResult = new string[0];
            }
            else
            {
                strResult = value.Split(CVS_SPLIT);
            }

            fieldInfo.SetValue(csv, strResult);
        }
Exemple #7
0
 public static void _internal_int_set_value(string value, FieldInfo fieldInfo, BaseCsv csv)
 {
     try
     {
         if (string.IsNullOrEmpty(value))
         {
             fieldInfo.SetValue(csv, 0);
         }
         else
         {
             fieldInfo.SetValue(csv, Int32.Parse(value));
         }
     }
     catch (Exception e)
     {
         LogManager.Error("[{0}],[{1}]", value, e.Message);
     }
 }