public static DoubleUIntKeyTable <T> CreateDoubleUIntKeyTable <T>(string text, CallBackDoubleUIntKeyReadCSV <T> cb, string name_table, CallBackDoubleUIntSecondKey cb_second_key, CallBackDoubleUIntParseKey cb_parse_first_key = null, CallBackDoubleUIntParseKey cb_parse_second_key = null, Progress progress = null) where T : new() { DoubleUIntKeyTable <T> doubleUIntKeyTable = new DoubleUIntKeyTable <T>(); int num = 0; CSVReader cSVReader = new CSVReader(text, name_table, false); float num2 = 1f; if (progress != null) { num2 = progress.value; } float num3 = 1f - num2; float num4 = (float)text.Length; while (cSVReader.NextLine()) { string value = string.Empty; string value2 = string.Empty; uint key = 0u; cSVReader.Pop(ref value); if (!string.IsNullOrEmpty(value)) { key = (cb_parse_first_key?.Invoke(value) ?? uint.Parse(value)); if (cb_second_key != null) { num = (((UIntKeyTable <UIntKeyTable <T> >)doubleUIntKeyTable).Get(key)?.GetCount() ?? 0); value2 = cb_second_key(cSVReader, num); } else { cSVReader.Pop(ref value2); } if (!string.IsNullOrEmpty(value2)) { uint key2 = 0u; key2 = (cb_parse_second_key?.Invoke(value2) ?? uint.Parse(value2)); T val = new T(); if (!cb(cSVReader, val, ref key, ref key2)) { doubleUIntKeyTable.Clear(); return(null); } UIntKeyTable <T> uIntKeyTable = ((UIntKeyTable <UIntKeyTable <T> >)doubleUIntKeyTable).Get(key); if (uIntKeyTable == null) { uIntKeyTable = new UIntKeyTable <T>(false); ((UIntKeyTable <UIntKeyTable <T> >)doubleUIntKeyTable).Add(key, uIntKeyTable); } uIntKeyTable.Add(key2, val); if (progress != null) { progress.value = num2 + num3 * (float)cSVReader.GetPosition() / num4; } } } } return(doubleUIntKeyTable); }
public static bool AddDoubleUIntKeyTable <T>(DoubleUIntKeyTable <T> table1, string text, CallBackDoubleUIntKeyReadCSV <T> cb, string name_table, CallBackDoubleUIntSecondKey cb_second_key, CallBackDoubleUIntParseKey cb_parse_first_key = null, CallBackDoubleUIntParseKey cb_parse_second_key = null) where T : new() { CSVReader cSVReader = new CSVReader(text, name_table, false); int num = 0; while (cSVReader.NextLine()) { string value = string.Empty; string value2 = string.Empty; uint key = 0u; cSVReader.Pop(ref value); if (!string.IsNullOrEmpty(value)) { key = (cb_parse_first_key?.Invoke(value) ?? uint.Parse(value)); if (cb_second_key != null) { num = (((UIntKeyTable <UIntKeyTable <T> >)table1).Get(key)?.GetCount() ?? 0); value2 = cb_second_key(cSVReader, num); } else { cSVReader.Pop(ref value2); } if (!string.IsNullOrEmpty(value2)) { uint key2 = 0u; key2 = (cb_parse_second_key?.Invoke(value2) ?? uint.Parse(value2)); T val = new T(); if (!cb(cSVReader, val, ref key, ref key2)) { return(false); } UIntKeyTable <T> uIntKeyTable = ((UIntKeyTable <UIntKeyTable <T> >)table1).Get(key); if (uIntKeyTable == null) { uIntKeyTable = new UIntKeyTable <T>(false); ((UIntKeyTable <UIntKeyTable <T> >)table1).Add(key, uIntKeyTable); } uIntKeyTable.Add(key2, val); } } } return(true); }