private void FromSBRecursion(Primitive sbArray, ListGen listTo, bool bValues) { Dictionary <Primitive, Primitive> _arrayMap = (Dictionary <Primitive, Primitive>)_fieldInfo.GetValue(Utilities.CreateArrayMap(sbArray)); if (_arrayMap.Count > 0) { foreach (KeyValuePair <Primitive, Primitive> kvp in _arrayMap) { Dictionary <Primitive, Primitive> _arrayMap1 = (Dictionary <Primitive, Primitive>)_fieldInfo.GetValue(Utilities.CreateArrayMap(kvp.Value)); listGen = new ListGen(); listTo.Add(listGen); if (_arrayMap1.Count > 0) { FromSBRecursion(kvp.Value, listGen, bValues); } else { listGen.Value = bValues ? kvp.Value : kvp.Key; } } } else { if (bValues) { listTo.Value = sbArray; } } }
private void CopyRecursion(ListGen listFrom, ListGen listTo) { for (int i = 0; i < listFrom.Count; i++) { listTo.Add(new ListGen()); listTo[i].Value = listFrom[i].Value; CopyRecursion(listFrom[i], listTo[i]); } }
private void ReadRecursion(ListGen listTo, BinaryReader br) { int num = br.ReadInt32(); if (num == 0) { listTo.Value = br.ReadString(); } for (int i = 0; i < num; i++) { listTo.Add(new ListGen()); ReadRecursion(listTo[i], br); } }
public void Set(Primitive value) { try { listGen = listGenMain; for (int i = 0; i < numIndex; i++) { int ind = index[i]; for (int j = listGen.Count; j < ind; j++) { listGen.Add(new ListGen()); } listGen = listGen[ind - 1]; } listGen.Value = value; } catch { } }
public void ReadCSV(string fileName) { try { string[] input = System.IO.File.ReadAllLines(fileName); string[] row; List <string[]> rowOrdered = new List <string[]>(); int numRow = input.Length; int numCol = 1; foreach (string line in input) { row = line.Split(new string[] { Utilities.CSV }, StringSplitOptions.None); numCol = System.Math.Max(numCol, row.Length); rowOrdered.Add(row); } listGenMain.Clear(); ListGen listGen1, listGen2; for (int iRow = 0; iRow < numRow; iRow++) { listGen1 = new ListGen(); listGenMain.Add(listGen1); row = rowOrdered[iRow]; for (int iCol = 0; iCol < row.Length; iCol++) { listGen2 = new ListGen(); listGen1.Add(listGen2); listGen2.Value = Utilities.CSVParse(row[iCol], false); } } } catch (Exception ex) { Utilities.OnError(Utilities.GetCurrentMethod(), ex); } }
public void Read(string fileName, bool binary) { try { if (binary) { using (FileStream fs = System.IO.File.Open(fileName, FileMode.Open)) { using (BinaryReader br = new BinaryReader(fs, Encoding.UTF8)) { listGenMain.Clear(); ReadRecursion(listGenMain, br); } } } else { using (FileStream fs = System.IO.File.Open(fileName, FileMode.Open)) { using (StreamReader sr = new StreamReader(fs, Encoding.UTF8)) { listGenMain.Clear(); while (sr.Peek() >= 0) { string line = sr.ReadLine(); string[] split = line.Split(' '); if (split.Length == 0) { continue; } List <int> indices = new List <int>(); int index; string value = ""; for (int i = 0; i < split.Length; i++) { if (split[i] == ":" && indices.Count > 0) { for (int j = i + 1; j < split.Length; j++) { value += split[j]; } break; } else if (int.TryParse(split[i], out index)) { indices.Add(index); } else { value = line; indices.Clear(); indices.Add(listGenMain.Count + 1); break; } } listGen = listGenMain; for (int i = 0; i < indices.Count; i++) { index = indices[i]; for (int j = listGen.Count; j < index; j++) { listGen.Add(new ListGen()); } listGen = listGen[index - 1]; } listGen.Value = value; } } } } } catch (Exception ex) { Utilities.OnError(Utilities.GetCurrentMethod(), ex); } }