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.
23 lines
629 B
23 lines
629 B
1 year ago
|
using System.Reactive.Linq;
|
||
|
using Recyclarr.TrashLib.Services.System;
|
||
|
|
||
|
namespace Recyclarr.TrashLib.Services.Common;
|
||
|
|
||
|
public abstract class ServiceCapabilityChecker<T> where T : class
|
||
|
{
|
||
|
private readonly IObservable<T?> _capabilities;
|
||
|
|
||
|
public T? GetCapabilities() => _capabilities.Wait();
|
||
|
|
||
|
protected ServiceCapabilityChecker(IServiceInformation info)
|
||
|
{
|
||
|
_capabilities = info.Version
|
||
|
.Select(x => x is null ? null : BuildCapabilitiesObject(x))
|
||
|
.Replay(1)
|
||
|
.AutoConnect()
|
||
|
.LastAsync();
|
||
|
}
|
||
|
|
||
|
protected abstract T BuildCapabilitiesObject(Version version);
|
||
|
}
|