/// <summary> /// 读取竖表 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="source"></param> private async CTask <T> readConfigV <T>() where T : BaseConfig, new() { string fileName = typeof(T).Name; UnityEngine.Object configObj = await CSF.Mgr.Assetbundle.LoadAsset <UnityEngine.Object>(configAssetbundle, fileName); if (configObj != null) { string strconfig = configObj.ToString(); if (IsCSV) { using (StringReader sr = new StringReader(strconfig)) { string line; while ((line = sr.ReadLine()) != null) { T config = CSF.ConfigUtils.ToObject <T>(line.Split(splitFieldChar)); return(config); } } } else { List <T> list = JsonMapper.ToObject <List <T> >(strconfig); if (list.Count > 0) { return(list[0]); } } } else { CLog.Error($"配置文件不存在{fileName}"); } return(default(T)); }
public static void Dump(object obj, string hint = "") { CLog.Log(DumpAsString(obj, hint)); }
private static void DoDump(object obj) { if (obj == null) { _text.Append("null"); _text.Append(","); return; } Type t = obj.GetType(); if (obj is IList) { _text.Append("["); IList list = obj as IList; for (int i = 0; i < list.Count; i++) { DoDump(list[i]); } _text.Append("]"); } else if (t.IsValueType || obj is string || obj is ByteString) { _text.Append(obj); _text.Append(","); AppendIndent(1); } else if (t.IsArray) { var a = (Array)obj; _text.Append("["); for (int i = 0; i < a.Length; i++) { _text.Append(i); _text.Append("="); DoDump(a.GetValue(i)); } _text.Append("]"); } else if (t.IsClass) { _text.Append(string.Format("<{0}>", t.Name)); _text.Append("{"); var fields = t.GetProperties(BindingFlags.Public | BindingFlags.Instance); if (fields.Length > 0) { for (int i = 0; i < fields.Length; i++) { _text.Append(fields[i].Name); _text.Append("="); var value = fields[i].GetGetMethod().Invoke(obj, null); DoDump(value); } } _text.Append("}"); } else { CLog.Warning("unsupport type: " + t.FullName); _text.Append(obj); _text.Append(","); AppendIndent(1); } }