123456789101112131415161718192021222324252627282930313233 |
- using System.Text.Json;
- using Microsoft.Extensions.Configuration;
- using System.IO;
- using System;
- namespace gameapi.Library
- {
- public class JsonFileReader : IJsonFileReader
- {
- private string path;
- public JsonFileReader()
- {
- path = GlobalConfiguration.Get().GetSection("gameapi").GetValue<string>("DataPath");
- }
- public dynamic Read(string filename)
- {
- var text = File.ReadAllText(filename);
- return JsonSerializer.Deserialize<dynamic>(text);
- }
- public dynamic ReadGameData(string filename)
- {
- var filePath = path + "/" + filename;
- return Read(filePath);
- }
- }
- public interface IJsonFileReader
- {
- dynamic Read(string filename);
- }
- }
|