static void add_dict_by_file(Dictionary <string, List <TableFunction> > dict, string file) { string path = @"c:\lib\lua\"; string pathfile = path + file; try { using (StreamReader r = new StreamReader(pathfile)) { string line; while ((line = r.ReadLine()) != null) { line.Trim(); if (line.Length < 2) { continue; } if (line.StartsWith("--")) //comment { continue; } TableFunction tf = new TableFunction(line); var table = tf.GetTable(); if (!dict.ContainsKey(table)) { dict[table] = new List <TableFunction>(); } dict[table].Add(tf); } } } catch (Exception e) { // Let the user know what went wrong. Console.WriteLine("The file could not be read:"); Console.WriteLine(e.Message); } }
static void add_dict_by_file(Dictionary<string, List<TableFunction>> dict, string file) { string path = @"c:\lib\lua\"; string pathfile = path + file; try { using (StreamReader r = new StreamReader(pathfile)) { string line; while ((line = r.ReadLine()) != null) { line.Trim(); if (line.Length < 2) continue; if (line.StartsWith("--")) //comment continue; TableFunction tf = new TableFunction(line); var table = tf.GetTable(); if (!dict.ContainsKey(table)) dict[table] = new List<TableFunction>(); dict[table].Add(tf); } } } catch (Exception e) { // Let the user know what went wrong. Console.WriteLine("The file could not be read:"); Console.WriteLine(e.Message); } }