You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Digitalisation_EPA_Serveur/BDAccess/APIAccess.cs

40 lines
932 B

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Runtime.CompilerServices;
using System.Text.Json;
using System.Threading.Tasks;
namespace EPAServeur.BDAccess
{
public class APIAccess
{
private static APIAccess instance = null;
private string serveur = "http://localhost:3000";
private APIAccess()
{
}
public static APIAccess getInstance()
{
return instance;
}
public static List<T> requestAPI<T>(string query)
{
if (instance == null)
{
instance = new APIAccess();
}
List<T> result = new List<T>();
WebClient client = new WebClient();
result = JsonSerializer.Deserialize<List<T>>(client.DownloadString(instance.serveur+query));
return result;
}
}
}