public static Stage LoadStageFromFile(string file_name) { //Create an empty stage that will be our result Stage result = new Stage(); //Grab all the lines from the file var file_lines = ConfigurationFileLoader.LoadConfigurationFile(file_name); for (int i = 0; i < file_lines.Count; i++) { var this_line = file_lines[i].Trim(); if (this_line.Equals("BEGIN STAGE")) { var file_lines_to_use = file_lines.GetRange(i + 1, file_lines.Count - i - 1).ToList(); //Parse the rest of the lines of the file if (file_lines_to_use.Count > 0) { //Create a root phase node PhaseNode root = new PhaseNode() { Command = "root" }; //Structure the list of commands StructurePhases(file_lines_to_use, 0, root); //Expand the phase node structure by instantiating each phase and putting them into a flat list ExpandPhaseNodes(result.StageSegments, null, root); } //Break out of the loop. We are done. break; } else { var line_parts = this_line.Split(new char[] { ':' }, 2).ToList(); if (line_parts.Count >= 2) { var param_name = line_parts[0].Trim(); var param_val = line_parts[1].Trim(); if (param_name.Equals("Stage Name")) { result.StageName = param_val; } else if (param_name.Equals("Stage Description")) { result.StageDescription = param_val; } } } } //Return the new stage return(result); }
public void LoadLanguageDictionaries() { List <LanguageDictionary> result = new List <LanguageDictionary>(); var all_dictionary_files = Directory.GetFiles(ResourcesFolder + DictionaryPath); foreach (var f in all_dictionary_files) { //Get the file info for this file FileInfo f_info = new FileInfo(f); //Instantiate a new language dictionary object LanguageDictionary d = new LanguageDictionary(); string filename = Path.GetFileNameWithoutExtension(f_info.Name); List <string> separated_parts = filename.Split(new char[] { '_' }).ToList(); d.ForeignLanguageName = separated_parts[0].ToLower(); if (separated_parts.Count >= 3) { d.NativeLanguageName = separated_parts[2].ToLower(); } else { d.NativeLanguageName = "english"; } if (separated_parts.Count >= 4) { d.MetaData = separated_parts[3].ToLower(); } //Load the dictionary file List <string> file_lines = ConfigurationFileLoader.LoadConfigurationFile(f); for (int i = 0; i < file_lines.Count; i++) { string this_line = file_lines[i]; string[] split_string = this_line.Split(new char[] { '\t' }, 2); string key = split_string[0].Trim(); string value = split_string[1].Trim(); d.DictionaryWordPairs.Add(new Tuple <string, string>(key, value)); } result.Add(d); } //Set the class property with the result LanguageDictionaries = result; }
public void LoadConfigurationFile() { //Load the configuration file List <string> file_lines = ConfigurationFileLoader.LoadConfigurationFile(ResourcesFolder + ConfigurationFileName); //Iterate through each line and parse out the data for (int i = 0; i < file_lines.Count; i++) { string this_line = file_lines[i]; string[] split_string = this_line.Split(new char[] { ':' }, 2); string key = split_string[0].Trim(); string value = split_string[1].Trim(); if (key.Equals("Primary Save Path", StringComparison.InvariantCultureIgnoreCase)) { PrimarySavePath = value; } } }