mirror of
https://github.com/Relintai/mono.git
synced 2024-11-08 10:12:16 +01:00
24 lines
671 B
C#
24 lines
671 B
C#
using GodotTools.IdeMessaging.Requests;
|
|
using GodotTools.IdeMessaging.Utils;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace GodotTools.IdeMessaging
|
|
{
|
|
public abstract class ResponseAwaiter : NotifyAwaiter<Response>
|
|
{
|
|
public abstract void SetResult(MessageContent content);
|
|
}
|
|
|
|
public class ResponseAwaiter<T> : ResponseAwaiter
|
|
where T : Response, new()
|
|
{
|
|
public override void SetResult(MessageContent content)
|
|
{
|
|
if (content.Status == MessageStatus.Ok)
|
|
SetResult(JsonConvert.DeserializeObject<T>(content.Body));
|
|
else
|
|
SetResult(new T {Status = content.Status});
|
|
}
|
|
}
|
|
}
|