public void LoadFromFile(string path) { foreach (List <string> line in Utilities.ReadCSV(path)) { bool isReal; bool.TryParse(line[2], out isReal); idNames.Add(line[0], new LookupResult(line[1], isReal)); } }
public static BiDictionaryOneToOne<string, LanguageInstruction> Parse(string[] languageDefinition) { var operators = new BiDictionaryOneToOne<string, LanguageInstruction>(); foreach (var line in languageDefinition) { var firstSpace = line.IndexOf(" "); string dilInstruction = line.Substring(0, firstSpace), languageToken = line.Substring(firstSpace + 1); operators.Add(languageToken, (LanguageInstruction)Enum.Parse(typeof(LanguageInstruction), dilInstruction)); } return operators; }
public static BiDictionaryOneToOne <string, LanguageInstruction> Parse(string[] languageDefinition) { var operators = new BiDictionaryOneToOne <string, LanguageInstruction>(); foreach (var line in languageDefinition) { var firstSpace = line.IndexOf(" "); string dilInstruction = line.Substring(0, firstSpace), languageToken = line.Substring(firstSpace + 1); operators.Add(languageToken, (LanguageInstruction)Enum.Parse(typeof(LanguageInstruction), dilInstruction)); } return(operators); }
public override Task OnConnected() { ApplicationRole.TryParse(Context.QueryString["ApplicationRole"], out ApplicationRole appRole); switch (appRole) { case ApplicationRole.Client: clientMapper.Add(Context.QueryString["userName"], Context.ConnectionId); Clients.Group(AdminGroup).ClientConnected(Context.QueryString["userName"]); break; case ApplicationRole.Server: Groups.Add(Context.ConnectionId, AdminGroup); break; } return(base.OnConnected()); }
private static void LoadCharList(string txtName, BiDictionaryOneToOne<byte, string> charList, Dictionary<string, uint> sizeList) { string filename = Path.Combine(Application.StartupPath, txtName); string text = File.ReadAllText(filename); string[] lines = text.Split(new string[] { "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < lines.Length; i++) { // Ignore comments if (lines[i].ToCharArray()[0] == '#') continue; string[] pair = lines[i].Split('='); if (pair.Length < 3) continue; try { charList.Add(byte.Parse(pair[0]), pair[2]); sizeList.Add(pair[2], uint.Parse(pair[1])); } catch (Exception e) { MessageBox.Show("Error in " + filename + "\n\n" + "Line " + i + "\n\n" + pair[0] + "\t" + pair[1] + "\t" + pair[2]); } } }
/* Reads in the list of known Global Collision Type values */ private void loadGlobalCLPSTypes() { GLOBAL_CLPS_TYPES = new BiDictionaryOneToOne<string, byte[]>(new ByteArrayComparer()); string entryName = ""; byte[] entryValue = new byte[8]; int valueCount = 0; // Create an XML reader for this file. using (XmlReader reader = XmlReader.Create(Path.Combine(Application.StartupPath, "CLPS_Types.xml"))) { reader.MoveToContent(); while (reader.Read()) { if (reader.NodeType.Equals(XmlNodeType.Element)) { switch (reader.LocalName) { case "Entry": entryName = reader.GetAttribute("name"); break; case "Value": entryValue = new byte[8]; valueCount = 0; break; case "Byte": entryValue[valueCount] = Byte.Parse(reader.ReadElementContentAsString()); valueCount++; break; } } else if (reader.NodeType.Equals(XmlNodeType.EndElement)) { switch (reader.LocalName) { case "Entry": GLOBAL_CLPS_TYPES.Add(entryName, entryValue); break; } } } } }