Fixing a bug when open the nameseditor directly after start that images are not created

This commit is contained in:
BlubbFish 2021-08-29 00:48:41 +02:00
parent 47fe56304f
commit 6702c6392c

View File

@ -8,6 +8,8 @@ using BlubbFish.Utils;
namespace Fraunhofer.Fit.IoT.LoraMap.Model.Svg {
public class SvgModel : OwnSingeton<SvgModel> {
private readonly Dictionary<String, SVGFile> svgtable = new Dictionary<String, SVGFile>();
private readonly Object lockSVG = new Object();
public Boolean ParseRequest(HttpListenerContext cont) {
Byte[] svg = this.GetSvg(cont.Request.Url.PathAndQuery);
if(svg.Length > 0) {
@ -26,6 +28,7 @@ namespace Fraunhofer.Fit.IoT.LoraMap.Model.Svg {
if(this.svgtable.ContainsKey(pathAndQuery)) {
return Encoding.UTF8.GetBytes(this.svgtable[pathAndQuery].ToString());
} else {
lock(this.lockSVG) {
if(pathAndQuery.StartsWith("/api/svg/marker.svg") && pathAndQuery.Contains("?")) {
String query = pathAndQuery[(pathAndQuery.IndexOf('?') + 1)..];
this.svgtable.Add(pathAndQuery, new SVGMarker(query));
@ -36,6 +39,7 @@ namespace Fraunhofer.Fit.IoT.LoraMap.Model.Svg {
return Encoding.UTF8.GetBytes(this.svgtable[pathAndQuery].ToString());
}
}
}
return new Byte[0];
}
}