public static void GenDataClass(string excelPath, string calssName) { var excelLoader = new ExcelLoader(excelPath); var paramTypeDict = excelLoader.ParseOneRow(Config.TYPE_ROW_INDEX); var paramNameDict = excelLoader.ParseOneRow(Config.NAME_ROW_INDEX); GenDataClass(calssName, paramTypeDict, paramNameDict); }
protected static List <T> CreateDataList <T>(ExcelLoader loader) where T : new() { var list = new List <T>(); T data; FieldInfo field; var type = typeof(T); loader.ParseParamNameRow(); loader.ParseParamTypeRow(); loader.ParseIdColumn(); var rowItor = loader.idDict.GetEnumerator(); while (rowItor.MoveNext()) { data = new T(); var colItor = loader.paramTypeDict.GetEnumerator(); while (colItor.MoveNext()) { if (!loader.paramNameDict.ContainsKey(colItor.Current.Key)) { Debug.LogError("Error, ParamName row does not have key:" + colItor.Current.Key); return(null); } field = type.GetField(loader.paramNameDict[colItor.Current.Key], BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Public); if (field != null) { field.SetValue(data, loader.GetCellData(colItor.Current.Value, rowItor.Current.Key, colItor.Current.Key)); } } list.Add(data); } return(list); }