Use string interpolation

This commit is contained in:
Clemens 2022-01-20 22:15:43 +01:00
parent b69beda620
commit 6e02ea2c61
5 changed files with 18 additions and 18 deletions

View file

@ -125,7 +125,7 @@ namespace MapControl
{ {
if (!double.TryParse(line, NumberStyles.Float, CultureInfo.InvariantCulture, out double parameter)) if (!double.TryParse(line, NumberStyles.Float, CultureInfo.InvariantCulture, out double parameter))
{ {
throw new ArgumentException("Failed parsing line " + (i + 1) + " in world file \"" + worldFilePath + "\"."); throw new ArgumentException($"Failed parsing line {i + 1} in world file {worldFilePath}.");
} }
return parameter; return parameter;
}) })
@ -133,7 +133,7 @@ namespace MapControl
if (parameters.Count != 6) if (parameters.Count != 6)
{ {
throw new ArgumentException("Insufficient number of parameters in world file \"" + worldFilePath + "\"."); throw new ArgumentException($"Insufficient number of parameters in world file {worldFilePath}.");
} }
return new Matrix( return new Matrix(

View file

@ -134,7 +134,7 @@ namespace MapControl
if (docEntry == null) if (docEntry == null)
{ {
throw new ArgumentException("No KML entry found in " + archiveFilePath); throw new ArgumentException($"No KML entry found in {archiveFilePath}.");
} }
var imageOverlays = await Task.Run(() => var imageOverlays = await Task.Run(() =>

View file

@ -60,7 +60,7 @@ namespace MapControl
if (layerElement == null) if (layerElement == null)
{ {
throw new ArgumentException("Layer element \"" + layerIdentifier + "\" not found."); throw new ArgumentException($"Layer element \"{layerIdentifier}\" not found.");
} }
} }
else else
@ -87,7 +87,7 @@ namespace MapControl
if (string.IsNullOrEmpty(style)) if (string.IsNullOrEmpty(style))
{ {
throw new ArgumentException("No valid Style element found in Layer \"" + layerIdentifier + "\"."); throw new ArgumentException($"No valid Style element found in Layer \"{layerIdentifier}\".");
} }
var urlTemplate = ReadUrlTemplate(layerElement, layerIdentifier, style, capabilitiesUrl); var urlTemplate = ReadUrlTemplate(layerElement, layerIdentifier, style, capabilitiesUrl);
@ -107,7 +107,7 @@ namespace MapControl
if (tileMatrixSetElement == null) if (tileMatrixSetElement == null)
{ {
throw new ArgumentException("Linked TileMatrixSet element not found in Layer \"" + layerIdentifier + "\"."); throw new ArgumentException($"Linked TileMatrixSet element not found in Layer \"{layerIdentifier}\".");
} }
tileMatrixSets.Add(ReadTileMatrixSet(tileMatrixSetElement)); tileMatrixSets.Add(ReadTileMatrixSet(tileMatrixSetElement));
@ -150,7 +150,7 @@ namespace MapControl
if (formats.Count == 0) if (formats.Count == 0)
{ {
throw new ArgumentException("No Format element found in Layer \"" + layerIdentifier + "\"."); throw new ArgumentException($"No Format element found in Layer \"{layerIdentifier}\".");
} }
var format var format
@ -174,7 +174,7 @@ namespace MapControl
if (string.IsNullOrEmpty(urlTemplate)) if (string.IsNullOrEmpty(urlTemplate))
{ {
throw new ArgumentException("No valid ResourceURL element found in Layer \"" + layerIdentifier + "\"."); throw new ArgumentException($"No valid ResourceURL element found in Layer \"{layerIdentifier}\".");
} }
return urlTemplate; return urlTemplate;
@ -196,7 +196,7 @@ namespace MapControl
if (string.IsNullOrEmpty(supportedCrs)) if (string.IsNullOrEmpty(supportedCrs))
{ {
throw new ArgumentException("No ows:SupportedCRS element found in TileMatrixSet \"" + identifier + "\"."); throw new ArgumentException($"No ows:SupportedCRS element found in TileMatrixSet \"{identifier}\".");
} }
var tileMatrixes = new List<WmtsTileMatrix>(); var tileMatrixes = new List<WmtsTileMatrix>();
@ -208,7 +208,7 @@ namespace MapControl
if (tileMatrixes.Count <= 0) if (tileMatrixes.Count <= 0)
{ {
throw new ArgumentException("No TileMatrix elements found in TileMatrixSet \"" + identifier + "\"."); throw new ArgumentException($"No TileMatrix elements found in TileMatrixSet \"{identifier}\".");
} }
return new WmtsTileMatrixSet(identifier, supportedCrs, tileMatrixes); return new WmtsTileMatrixSet(identifier, supportedCrs, tileMatrixes);
@ -231,7 +231,7 @@ namespace MapControl
if (string.IsNullOrEmpty(valueString) || if (string.IsNullOrEmpty(valueString) ||
!double.TryParse(valueString, NumberStyles.Float, CultureInfo.InvariantCulture, out double scaleDenominator)) !double.TryParse(valueString, NumberStyles.Float, CultureInfo.InvariantCulture, out double scaleDenominator))
{ {
throw new ArgumentException("No ScaleDenominator element found in TileMatrix \"" + identifier + "\"."); throw new ArgumentException($"No ScaleDenominator element found in TileMatrix \"{identifier}\".");
} }
valueString = tileMatrixElement.Element(ns + "TopLeftCorner")?.Value; valueString = tileMatrixElement.Element(ns + "TopLeftCorner")?.Value;
@ -242,35 +242,35 @@ namespace MapControl
!double.TryParse(topLeftCornerStrings[0], NumberStyles.Float, CultureInfo.InvariantCulture, out double left) || !double.TryParse(topLeftCornerStrings[0], NumberStyles.Float, CultureInfo.InvariantCulture, out double left) ||
!double.TryParse(topLeftCornerStrings[1], NumberStyles.Float, CultureInfo.InvariantCulture, out double top)) !double.TryParse(topLeftCornerStrings[1], NumberStyles.Float, CultureInfo.InvariantCulture, out double top))
{ {
throw new ArgumentException("No TopLeftCorner element found in TileMatrix \"" + identifier + "\"."); throw new ArgumentException($"No TopLeftCorner element found in TileMatrix \"{identifier}\".");
} }
valueString = tileMatrixElement.Element(ns + "TileWidth")?.Value; valueString = tileMatrixElement.Element(ns + "TileWidth")?.Value;
if (string.IsNullOrEmpty(valueString) || !int.TryParse(valueString, out int tileWidth)) if (string.IsNullOrEmpty(valueString) || !int.TryParse(valueString, out int tileWidth))
{ {
throw new ArgumentException("No TileWidth element found in TileMatrix \"" + identifier + "\"."); throw new ArgumentException($"No TileWidth element found in TileMatrix \"{identifier}\".");
} }
valueString = tileMatrixElement.Element(ns + "TileHeight")?.Value; valueString = tileMatrixElement.Element(ns + "TileHeight")?.Value;
if (string.IsNullOrEmpty(valueString) || !int.TryParse(valueString, out int tileHeight)) if (string.IsNullOrEmpty(valueString) || !int.TryParse(valueString, out int tileHeight))
{ {
throw new ArgumentException("No TileHeight element found in TileMatrix \"" + identifier + "\"."); throw new ArgumentException($"No TileHeight element found in TileMatrix \"{identifier}\".");
} }
valueString = tileMatrixElement.Element(ns + "MatrixWidth")?.Value; valueString = tileMatrixElement.Element(ns + "MatrixWidth")?.Value;
if (string.IsNullOrEmpty(valueString) || !int.TryParse(valueString, out int matrixWidth)) if (string.IsNullOrEmpty(valueString) || !int.TryParse(valueString, out int matrixWidth))
{ {
throw new ArgumentException("No MatrixWidth element found in TileMatrix \"" + identifier + "\"."); throw new ArgumentException($"No MatrixWidth element found in TileMatrix \"{identifier}\".");
} }
valueString = tileMatrixElement.Element(ns + "MatrixHeight")?.Value; valueString = tileMatrixElement.Element(ns + "MatrixHeight")?.Value;
if (string.IsNullOrEmpty(valueString) || !int.TryParse(valueString, out int matrixHeight)) if (string.IsNullOrEmpty(valueString) || !int.TryParse(valueString, out int matrixHeight))
{ {
throw new ArgumentException("No MatrixHeight element found in TileMatrix \"" + identifier + "\"."); throw new ArgumentException($"No MatrixHeight element found in TileMatrix \"{identifier}\".");
} }
var topLeft = supportedCrs == "EPSG:4326" var topLeft = supportedCrs == "EPSG:4326"

View file

@ -38,7 +38,7 @@ namespace MapControl
} }
else else
{ {
throw new ArgumentException("No coordinate transformation found in \"" + sourcePath + "\"."); throw new ArgumentException($"No coordinate transformation found in {sourcePath}.");
} }
if (metadata.GetQuery(NoDataQuery) is string noData && int.TryParse(noData, out int noDataValue)) if (metadata.GetQuery(NoDataQuery) is string noData && int.TryParse(noData, out int noDataValue))

View file

@ -56,7 +56,7 @@ namespace MapControl
} }
else else
{ {
throw new ArgumentException("No coordinate transformation found in \"" + sourcePath + "\"."); throw new ArgumentException($"No coordinate transformation found in {sourcePath}.");
} }
return new Tuple<BitmapSource, Matrix>(bitmap, transform); return new Tuple<BitmapSource, Matrix>(bitmap, transform);