Annotation

This commit is contained in:
Jöran Malek 2023-12-12 01:14:28 +01:00
parent 11a5549818
commit 58be1ee178
2 changed files with 11 additions and 3 deletions

View file

@ -8,12 +8,17 @@ public interface IMethod
public abstract static string Method { get; } public abstract static string Method { get; }
} }
public abstract class Method<TSelf> where TSelf : Method<TSelf>, IMethod [JsonPolymorphic(TypeDiscriminatorPropertyName = "method")]
[JsonDerivedType(typeof(InitializeMethod), "initialize")]
[JsonDerivedType(typeof(LookupMethod), "lookup")]
public abstract class Method
{ {
[JsonExtensionData] [JsonExtensionData]
public Dictionary<string, JsonElement> ExtensionData { get; } = []; public Dictionary<string, JsonElement> ExtensionData { get; } = [];
} }
public abstract class Method<TSelf> : Method where TSelf : Method<TSelf>, IMethod;
public abstract class Method<TSelf, TParam>(TParam parameters) : Method<TSelf> where TSelf : Method<TSelf, TParam>, IMethod public abstract class Method<TSelf, TParam>(TParam parameters) : Method<TSelf> where TSelf : Method<TSelf, TParam>, IMethod
{ {
public TParam Parameters => parameters; public TParam Parameters => parameters;

View file

@ -38,8 +38,11 @@ public class PowerDnsStreamClient : IDisposable
other.Cancel(); other.Cancel();
} }
private Task Run(CancellationToken stoppingToken) private async Task Run(CancellationToken stoppingToken)
{ {
return Task.CompletedTask; while (!stoppingToken.IsCancellationRequested)
{
await JsonSerializer.DeserializeAsync<Method>(_stream, cancellationToken: stoppingToken);
}
} }
} }