public SourceforgeVersionRetriever(bool findBeta) { Console.WriteLine("looking up sf"); FindOnPage findSchema = new FindOnPage { Url = "https://sourceforge.net/projects/packfilemanager/files/Schemata/", ToFind = findBeta ? beta_schema_file_re : schema_file_re }; FindOnPage findPfmVersion = new FindOnPage { Url = "https://sourceforge.net/projects/packfilemanager/files/Release/", ToFind = pfm_file_re }; Thread[] findThreads = new Thread[] { new Thread(findSchema.Search), new Thread(findPfmVersion.Search) }; foreach (Thread t in findThreads) { t.Start(); } foreach (Thread t in findThreads) { t.Join(); } LatestSchemaFile = findSchema.Result; LatestPfmFile = findPfmVersion.Result; if (LatestPfmFile == null || LatestSchemaFile == null) { throw new InvalidDataException(string.Format("Could not determine latest versions: got {0}, {1}", LatestPfmFile, LatestSchemaFile)); } #if DEBUG Console.WriteLine("Current versions: pfm {0}, schema {1}", LatestPfmFile, LatestSchemaFile); #endif }
//TODO Constructors shouldn't be doing logic. public SourceforgeVersionRetriever(bool findBeta) { Console.WriteLine("looking up sf"); //FIXME This is an artificial method of changing TLS version. It requires a newer version of .NET be installed than the program uses and thus the program should be migrated to a newer version since we are trying to use newer features than the required .NET version has. ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072; FindOnPage findSchema = new FindOnPage { Url = "https://sourceforge.net/projects/packfilemanager/files/Schemata/", ToFind = findBeta ? beta_schema_file_re : schema_file_re }; FindOnPage findPfmVersion = new FindOnPage { Url = "https://sourceforge.net/projects/packfilemanager/files/Release/", ToFind = pfm_file_re }; Thread[] findThreads = new Thread[] { new Thread(findSchema.Search), new Thread(findPfmVersion.Search) }; foreach (Thread t in findThreads) { t.Start(); } foreach (Thread t in findThreads) { t.Join(); } LatestSchemaFile = findSchema.Result; LatestPfmFile = findPfmVersion.Result; if (LatestPfmFile == null || LatestSchemaFile == null) { throw new InvalidDataException(string.Format("Could not determine latest versions: got {0}, {1}", LatestPfmFile, LatestSchemaFile)); } #if DEBUG Console.WriteLine("Current versions: pfm {0}, schema {1}", LatestPfmFile, LatestSchemaFile); #endif }