public static bool ReaderPList(String _tabName, int valueNum, SerializableTable _fun, Hashtable _hash, DataTableStructure _tableStructture, bool _isDeseriaAll) { TextAsset txtAsset = Resources.Load(_tabName, typeof(TextAsset)) as TextAsset; string[] alldataRow = txtAsset.text.Split('\n'); string[] values = new string[valueNum]; int cnt = alldataRow.Length; string line = ""; for (int idx = 0; idx < cnt; ++idx) { line = alldataRow[idx]; if (String.IsNullOrEmpty(line)) { continue; } string[] strCol = line.Split('\t'); if (strCol.Length == 0) { continue; } string skey = strCol[0]; Array.Copy(strCol, 1, values, 0, valueNum); if (string.IsNullOrEmpty(skey)) { return(false); } _fun(values, int.Parse(skey), _hash); } return(true); }
public static bool ReaderPList(String xmlFile, SerializableTable _fun, Hashtable _hash) { XmlDocument xml = new XmlDocument(); xml.Load(xmlFile); XmlNode rootNode = xml.SelectSingleNode("plist"); if (rootNode == null) { return(false); } rootNode = rootNode.SelectSingleNode("dict"); if (rootNode == null) { return(false); } XmlNodeList xnl = rootNode.ChildNodes; foreach (XmlNode xnf in xnl) { string skey = ""; if (xnf.Name == "key") { skey = xnf.InnerText; } if (string.IsNullOrEmpty(skey)) { return(false); } ArrayList valuesList = new ArrayList(); XmlNode skeys = xnf.NextSibling; XmlNodeList subList = skeys.ChildNodes; foreach (XmlNode values in subList) { valuesList.Add(values.InnerText); } _fun(valuesList, skey, _hash); } return(true); }
public void GivenWeHaveTheFollowingExistingEntries(Table table) { var tableSerialized = new SerializableTable(table); Deleporter.Run(() => { var originalRepository = IoC.CurrentGuestbookEntryRepository; TidyUp.AddTask(() => { IoC.CurrentGuestbookEntryRepository = originalRepository; }); var mockRepository = new Mock <IGuestbookEntryRepository>(); mockRepository.Setup(x => x.Entries) .Returns((from row in tableSerialized.Rows select new GuestbookEntry { Author = row["Name"], Comment = row["Comment"], PostedDate = Convert.ToDateTime(row["Posted date"]) }).AsQueryable()); IoC.CurrentGuestbookEntryRepository = mockRepository.Object; }); }
public JsonRow(SerializableTable table, int index, IStorageEngine engine) { _table = table; _row = index; Engine = engine; }
public static bool ReaderPList(String xmlFile, SerializableTable _fun, Dictionary <int, List <object> > _hash) { string m_Key = ""; string[] m_Value = null; string[] list = xmlFile.Split('.'); string relTablePath = list[0].Substring(7); string tableFilePath = GetLoadPath(relTablePath); string[] alldataRow; if (File.Exists(tableFilePath)) { StreamReader sr = null; sr = File.OpenText(tableFilePath); string tableData = sr.ReadToEnd(); sr.Close(); alldataRow = tableData.Split('\n'); sr.Dispose(); } else { TextAsset testAsset = Resources.Load(list[0], typeof(TextAsset)) as TextAsset; alldataRow = testAsset.text.Split('\n'); } //skip fort three int skip = 0; string[] typeList = null; foreach (string line in alldataRow) { int nKey = -1; if (skip == 1) { string sztemp = line; if (sztemp.Length >= 1) { if (sztemp[sztemp.Length - 1] == '\r') { sztemp = sztemp.TrimEnd('\r'); } } typeList = line.Split('\t'); m_Value = new string[typeList.Length]; ++skip; continue; } if (++skip < 4) { continue; } if (String.IsNullOrEmpty(line)) { continue; } if (line[0] == '#') { continue; } string szlinetemp = line; if (szlinetemp.Length >= 1) { if (szlinetemp[szlinetemp.Length - 1] == '\r') { szlinetemp = szlinetemp.TrimEnd('\r'); } } string[] strCol = MySplit(szlinetemp, typeList, "\t"); if (strCol.Length == 0) { continue; } string skey = strCol[0]; string[] valuesList = new string[strCol.Length]; if (string.IsNullOrEmpty(skey) || skey.Equals("--")) { skey = m_Key; nKey = Int32.Parse(skey); valuesList[0] = skey; for (int i = 1; i < strCol.Length; ++i) { if (String.IsNullOrEmpty(strCol[i]) || strCol[i] == "--") { valuesList[i] = m_Value[i]; } else { valuesList[i] = strCol[i]; m_Value[i] = strCol[i]; } } } else { m_Key = skey; nKey = Int32.Parse(skey); for (int i = 0; i < strCol.Length; ++i) { if (strCol[i] == "--") { valuesList[i] = "0"; m_Value[i] = "0"; } else { valuesList[i] = strCol[i]; m_Value[i] = strCol[i]; } } } _fun(valuesList, nKey, _hash); } return(true); }