public S3FileStorageTestsFixture() { string codeBase = Assembly.GetExecutingAssembly().CodeBase; UriBuilder uri = new UriBuilder(codeBase); string path = Uri.UnescapeDataString(uri.Path); string fileName = Path.GetDirectoryName(path) + "\\" + "TifWorldFileTest.tfw"; TfwParser = new TifWorldFileParser <Guid, S3BucketStorageLocation>(); TfwFile = TfwParser.GetTifWorldFileFromMetadataFile(fileName); }
public TifWorldFile <TPrimaryKey, TFileStorageLocationType> GetTifWorldFileFromMetadataFile(string metadataFileName) { TifWorldFile <TPrimaryKey, TFileStorageLocationType> file = null; // Tif World File metadata files are in .tfw format // ReSharper disable once RedundantAssignment var metadataFileText = string.Empty; if (!metadataFileName.EndsWith(".tfw")) { return(null); } try { // Open the Metadata text file using (StreamReader sr = new StreamReader(metadataFileName, Encoding.GetEncoding("iso-8859-1"))) { decimal a = new decimal(); decimal d = new decimal(); decimal b = new decimal(); decimal e = new decimal(); decimal c = new decimal(); decimal f = new decimal(); string lineText; int lineNumber = 1; while ((lineText = sr.ReadLine()) != null) { if (lineNumber == 1) { a = Decimal.Parse(lineText, NumberStyles.Float); } else if (lineNumber == 2) { d = Decimal.Parse(lineText, NumberStyles.Float); } else if (lineNumber == 3) { b = Decimal.Parse(lineText, NumberStyles.Float); } else if (lineNumber == 4) { e = Decimal.Parse(lineText, NumberStyles.Float); } else if (lineNumber == 5) { c = Decimal.Parse(lineText, NumberStyles.Float); } else if (lineNumber == 6) { f = Decimal.Parse(lineText, NumberStyles.Float); } lineNumber++; } file = new TifWorldFile <TPrimaryKey, TFileStorageLocationType>() { A = a, D = d, B = b, E = e, C = c, F = f }; } } catch (Exception ex) { throw new FileLoadException(ex.Message); } return(file); }