: ConfigModel where T : class {
+ public ConfigModel(string key) : base(key) {
+ DataList = new List| ();
+ }
+
+ public List | DataList {
+ get;
+ set;
+ }
+
+ public override object Parse(IReadOnlyDictionary dictionary,
+ UnityAction errorCallback = null) {
+ return LoadConfigList(dictionary, errorCallback);
+ }
+
+ protected override T1 LoadConfigList(IReadOnlyDictionary dictionary,
+ UnityAction errorCallback = null) {
+ ParseConfig(dictionary, out List| data, errorCallback);
+ DataList = data;
+ return this as T1;
+ }
+ }
+
+ public class ConfigModel : ConfigModel {
+ public ConfigModel(string key) : base(key) {
+ }
+
+ public override object Parse(IReadOnlyDictionary dictionary,
+ UnityAction errorCallback = null) {
+ return LoadConfig(dictionary, errorCallback);
+ }
+ }
+
+ public class ConfigModel {
+ protected readonly string Key;
+ public bool IsList = false;
+
+ protected ConfigModel(string key) {
+ Key = key;
+ }
+
+ public virtual object Parse(IReadOnlyDictionary dictionary,
+ UnityAction errorCallback = null) {
+ return null;
+ }
+
+ protected T LoadConfig(IReadOnlyDictionary dictionary,
+ UnityAction errorCallback = null) {
+ if (ParseConfig(dictionary, out T data, errorCallback)) {
+ return data;
+ }
+
+ return default;
+ }
+
+ protected virtual T LoadConfigList(IReadOnlyDictionary dictionary,
+ UnityAction errorCallback = null) where T : class {
+ return default;
+ }
+
+ protected bool ParseConfig(IReadOnlyDictionary dictionary, out T obj,
+ UnityAction errorCallback = null) {
+ obj = default;
+ if (!dictionary.TryGetValue(Key, out var data)) {
+ errorCallback?.Invoke(Key, "Excel Not find Sheet");
+ Log.ConfigLoader.Warning($"Excel Not find Sheet: {Key}");
+ return false;
+ }
+
+ var config = data.ToString();
+ try {
+ var tempObj = SerializeHelper.ToObject(config);
+
+ if (tempObj != null) {
+#if !GAME_RELEASE
+ CheckFields(Key, tempObj, config, FieldCheckType.Missing);
+ CheckFields(Key, tempObj, config, FieldCheckType.Extra);
+#endif
+ obj = tempObj;
+ return true;
+ }
+ }
+ catch (Exception ex) {
+ errorCallback?.Invoke(Key, ex.Message);
+ // 在此处添加异常处理逻辑,例如日志记录
+ Log.ConfigLoader.Error("Error deserializing config data for type " + typeof(T).Name + ": " + ex.Message);
+ }
+
+ return false;
+ }
+
+ private void CheckFields(string key, T tempObj, string configValue, FieldCheckType checkType) {
+ List fields;
+
+ if (tempObj is IEnumerable | |