godot/modules/mono/editor/GodotTools/GodotTools.IdeMessaging/ResponseAwaiter.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

24 lines
673 B
C#
Raw Normal View History

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
2022-08-27 01:22:23 +00:00
SetResult(new T { Status = content.Status });
}
}
}