static public object[] Load(string fileName, Type clazz) { object[] obj = null; try { CSVTable.CSVItem[] properts = Load(fileName); if (properts != null) { int size = properts.Length - 1; obj = (object[])Arrays.NewInstance(clazz, size); for (int i = 0; i < size; i++) { CSVTable.CSVItem property = properts[i]; if (property != null) { ArrayMap.Entry[] entry = property.ToEntrys(); obj[i] = Activator.CreateInstance(clazz); for (int j = 0; j < entry.Length; j++) { ArrayMap.Entry e = entry[j]; Register(obj[i], (string)e.GetKey(), (string)e.GetValue()); } } } properts = null; } } catch (Exception ex) { throw new Exception(ex + " " + fileName); } return(obj); }
static public CSVTable.CSVItem[] Load(string fileName) { CSVTable.CSVItem[] items = null; try { CSVReader csv = new CSVReader(fileName); List<string> tables = csv.ReadLineAsList(); int length = tables.Count; if (length > 0) { items = new CSVTable.CSVItem[length]; int count = 0; for (; csv.Ready(); ) { items[count] = new CSVTable.CSVItem(); string[] value_ren = csv.ReadLineAsArray(); for (int i = 0; i < length; i++) { items[count].Put(tables[i], value_ren[i]); items[count].index = i; } count++; } } if (csv != null) { csv.Close(); csv = null; } } catch (IOException ex) { Loon.Utils.Debug.Log.Exception(ex); } return items; }
static public CSVTable.CSVItem[] Load(string fileName) { CSVTable.CSVItem[] items = null; try { CSVReader csv = new CSVReader(fileName); List <string> tables = csv.ReadLineAsList(); int length = tables.Count; if (length > 0) { items = new CSVTable.CSVItem[length]; int count = 0; for (; csv.Ready();) { items[count] = new CSVTable.CSVItem(); string[] value_ren = csv.ReadLineAsArray(); for (int i = 0; i < length; i++) { items[count].Put(tables[i], value_ren[i]); items[count].index = i; } count++; } } if (csv != null) { csv.Close(); csv = null; } } catch (IOException ex) { Loon.Utils.Debug.Log.Exception(ex); } return(items); }