public static ParserFormatList ReadFromOptionFile(string sectionName) { string optionFile = AppDomain.CurrentDomain.BaseDirectory + "/MiscOptions.xml"; if (File.Exists(optionFile)) { var result = new ParserFormatList(); result.ReadFromFile(optionFile, sectionName); result.Sort((p1, p2) => p1.GUInameIndex - p2.GUInameIndex); return(result); } else { bool designMode = (LicenseManager.UsageMode == LicenseUsageMode.Designtime); if (!designMode) { Console.Error.WriteLine(string.Format("Cannot find option file {0}", optionFile)); throw new Exception(string.Format("Cannot find option file {0}", optionFile)); } else { return(new ParserFormatList()); } } }
public void TestReadFromFile() { Console.WriteLine(Application.ExecutablePath); var list = new ParserFormatList(); list.ReadFromFile(optionFile, "DatabaseParseDefinitions"); Assert.AreEqual(4, list.Count); Assert.AreEqual("IPI", list[0].FormatName); Assert.AreEqual("33001", list[0].FormatId); Assert.AreEqual("IPI:IPI00022229.1|SWISS-PROT:P04114|...", list[0].Sample); Assert.AreEqual(1, list[0].Count); Assert.AreEqual("accessNumber", list[0][0].ItemName); Assert.AreEqual(@"(IPI\d+)", list[0][0].RegularExpression); Assert.AreEqual(1.0, list[0][0].Slope); Assert.AreEqual(0.0, list[0][0].Offset); }
public static ParserFormatList ReadFromOptionFile(string sectionName) { var executeDir = FileUtils.GetAssemblyPath(); if (Directory.Exists(executeDir)) { string optionFile = executeDir + "\\MiscOptions.xml"; if (File.Exists(optionFile)) { var result = new ParserFormatList(); result.ReadFromFile(optionFile, sectionName); result.Sort((p1, p2) => p1.GUInameIndex - p2.GUInameIndex); return(result); } } return(null); }