예제 #1
0
        // Token: 0x06002364 RID: 9060 RVA: 0x000AD420 File Offset: 0x000AB620
        public static T PaddingData <T>(string csvName, int row) where T : new()
        {
            T        t        = Activator.CreateInstance <T>();
            object   obj      = t;
            CsvTable csvTable = CsvHelper.Get(csvName);

            if (csvTable == null)
            {
                return(t);
            }
            if (row < 0 || row > csvTable.RowCount)
            {
                return(t);
            }
            foreach (FieldInfo fieldInfo in typeof(T).GetFields())
            {
                string value = csvTable.Read(row, fieldInfo.Name);
                if (!string.IsNullOrEmpty(value))
                {
                    try
                    {
                        object value2 = Convert.ChangeType(value, fieldInfo.FieldType);
                        fieldInfo.SetValue(obj, value2);
                    }
                    catch (Exception ex)
                    {
                        Debug.LogErrorFormat("Csv padding data error! {0}", new object[]
                        {
                            ex
                        });
                    }
                }
            }
            return((T)((object)obj));
        }
예제 #2
0
        // Token: 0x06002363 RID: 9059 RVA: 0x000AD3F0 File Offset: 0x000AB5F0
        public static T PaddingData <T>(string csvName, string id) where T : new()
        {
            T        result   = Activator.CreateInstance <T>();
            CsvTable csvTable = CsvHelper.Get(csvName);

            if (csvTable == null)
            {
                return(result);
            }
            int rowByID = csvTable.GetRowByID(id);

            return(CsvHelper.PaddingData <T>(csvName, rowByID));
        }