// FIXME: This ignores "factorial" .apsim simulations private List <string> GetSimulationNamesFrom(string FileName) { StreamReader In = new StreamReader(FileName); string Contents = In.ReadToEnd(); In.Close(); string Pattern; if (Path.GetExtension(FileName).ToLower() == ".con") { Pattern = "^\\[(.+)\\]"; } else if (Path.GetExtension(FileName) == ".apsim") { Pattern = "<simulation name=\"(.+)\""; } else { throw new Exception("Cannot find simulations in file: " + FileName); } List <string> Matches = new List <string>(); Regex rgx = new Regex(Pattern, RegexOptions.IgnoreCase | RegexOptions.Multiline); foreach (Match match in rgx.Matches(Contents)) { if (match.Groups.Count == 2) { string sim = match.Groups[1].Value; if (sim.IndexOf("enabled=\"no") < 0) { Matches.Add(StringManip.RemoveAfter(sim, '\"')); } } } return(Matches); }