27 lines
779 B
C#
27 lines
779 B
C#
using System.Text.Json;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace Pathfinding;
|
|
|
|
public class PathResult
|
|
{
|
|
[JsonInclude]public double distance;
|
|
[JsonInclude]public double weight;
|
|
[JsonInclude]public TimeSpan calcTime;
|
|
[JsonInclude]public List<PathNode> pathNodes;
|
|
|
|
[JsonConstructor]
|
|
public PathResult(TimeSpan calcTime, List<PathNode> pathNodes, double distance, double weight)
|
|
{
|
|
this.calcTime = calcTime;
|
|
this.pathNodes = pathNodes;
|
|
this.distance = distance;
|
|
this.weight = weight;
|
|
}
|
|
|
|
public static PathResult PathresultFromFile(string filePath)
|
|
{
|
|
return JsonSerializer.Deserialize<PathResult>(new FileStream(filePath, FileMode.Open, FileAccess.Read,
|
|
FileShare.Read))!;
|
|
}
|
|
} |