Add project files.

This commit is contained in:
Dima yawaflua Andreev
2024-06-22 23:21:48 +03:00
parent bc437be3dc
commit 7d6932fdc6
26 changed files with 626 additions and 0 deletions

23
Utils/Deserialization.cs Normal file
View File

@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace SPWorldsApi.Utils
{
internal static class Deserialization
{
public static TClass Deserialize<TClass>(this string body) where TClass : class
{
TClass? objectToReturn = JsonSerializer.Deserialize<TClass>(body);
if (objectToReturn == null)
throw new Exception($"Error with deserializing object");
else
return objectToReturn;
}
}
}