24 lines
No EOL
542 B
C#
24 lines
No EOL
542 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using Newtonsoft.Json;
|
|
|
|
public static class MoveLoader
|
|
{
|
|
public static List<Move> LoadAllMoves(string path)
|
|
{
|
|
if (!File.Exists(path))
|
|
{
|
|
return new List<Move>();
|
|
}
|
|
|
|
string json = File.ReadAllText(path);
|
|
|
|
var settings = new JsonSerializerSettings
|
|
{
|
|
Converters = { new MoveConverter() }
|
|
};
|
|
|
|
return JsonConvert.DeserializeObject<List<Move>>(json, settings) ?? new List<Move>();
|
|
}
|
|
} |