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.
26 lines
653 B
26 lines
653 B
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()
|
|
{
|
|
return _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);
|
|
}
|