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.
35 lines
1.2 KiB
35 lines
1.2 KiB
|
3 years ago
|
using Newtonsoft.Json;
|
||
|
|
using w230415_classes;
|
||
|
|
using w230415_classes.Intf;
|
||
|
|
|
||
|
|
namespace w230415_consoleapi
|
||
|
|
{
|
||
|
|
internal class Program
|
||
|
|
{
|
||
|
|
static void Main(string[] args)
|
||
|
|
{
|
||
|
|
string url = "http://localhost:5091/v1/casino/";
|
||
|
|
HttpClient client = new HttpClient();
|
||
|
|
|
||
|
|
var rr = client.GetAsync(url + "game").Result;
|
||
|
|
if (rr.StatusCode == System.Net.HttpStatusCode.OK)
|
||
|
|
{
|
||
|
|
string json = rr.Content.ReadAsStringAsync().Result;
|
||
|
|
////1. dynamic
|
||
|
|
// dynamic dynamicObject = JsonConvert.DeserializeObject(json);
|
||
|
|
// foreach(var c2 in dynamicObject)
|
||
|
|
// {
|
||
|
|
// Console.WriteLine(
|
||
|
|
// $"{c2.serial} // {c2.isActive}");
|
||
|
|
// }
|
||
|
|
////2. with self types
|
||
|
|
var result = JsonConvert.DeserializeObject<List<Game>>(json);
|
||
|
|
foreach (var c2 in result)
|
||
|
|
{
|
||
|
|
Console.WriteLine(
|
||
|
|
$"{c2.Serial} // {c2.IsActive}");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|