parent
1772e7c9fd
commit
6036be0d29
@ -1,8 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<ItemGroup>
|
||||
<PackageReference Include="FluentValidation" />
|
||||
<PackageReference Include="YamlDotNet" />
|
||||
<PackageReference Include="Autofac" />
|
||||
<PackageReference Include="FluentValidation" />
|
||||
<PackageReference Include="Newtonsoft.Json" />
|
||||
<PackageReference Include="Serilog" />
|
||||
<PackageReference Include="System.Reactive" />
|
||||
<PackageReference Include="YamlDotNet" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Reactive.Disposables;
|
||||
using System.Reactive.Linq;
|
||||
using System.Threading;
|
||||
using Serilog;
|
||||
|
||||
namespace Common.Extensions
|
||||
{
|
||||
public static class RxExtensions
|
||||
{
|
||||
public static IObservable<T> Spy<T>(this IObservable<T> source, ILogger log, string? opName = null)
|
||||
{
|
||||
opName ??= "IObservable";
|
||||
log.Debug("{OpName}: Observable obtained on Thread: {ThreadId}",
|
||||
opName,
|
||||
Thread.CurrentThread.ManagedThreadId);
|
||||
|
||||
return Observable.Create<T>(obs =>
|
||||
{
|
||||
log.Debug("{OpName}: Subscribed to on Thread: {ThreadId}",
|
||||
opName,
|
||||
Thread.CurrentThread.ManagedThreadId);
|
||||
|
||||
try
|
||||
{
|
||||
var subscription = source
|
||||
.Do(
|
||||
x => log.Debug("{OpName}: OnNext({Result}) on Thread: {ThreadId}", opName, x,
|
||||
Thread.CurrentThread.ManagedThreadId),
|
||||
ex => log.Debug("{OpName}: OnError({Result}) on Thread: {ThreadId}", opName, ex.Message,
|
||||
Thread.CurrentThread.ManagedThreadId),
|
||||
() => log.Debug("{OpName}: OnCompleted() on Thread: {ThreadId}", opName,
|
||||
Thread.CurrentThread.ManagedThreadId))
|
||||
.Subscribe(obs);
|
||||
return new CompositeDisposable(
|
||||
subscription,
|
||||
Disposable.Create(() => log.Debug(
|
||||
"{OpName}: Cleaned up on Thread: {ThreadId}",
|
||||
opName,
|
||||
Thread.CurrentThread.ManagedThreadId)));
|
||||
}
|
||||
finally
|
||||
{
|
||||
log.Debug("{OpName}: Subscription completed", opName);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -1,10 +1,10 @@
|
||||
using System;
|
||||
|
||||
namespace TrashLib.Sonarr
|
||||
{
|
||||
public interface ISonarrCompatibility
|
||||
{
|
||||
bool SupportsNamedReleaseProfiles { get; }
|
||||
bool ArraysNeededForReleaseProfileRequiredAndIgnored { get; }
|
||||
string InformationalVersion { get; }
|
||||
string MinimumVersion { get; }
|
||||
IObservable<SonarrCapabilities> Capabilities { get; }
|
||||
Version MinimumVersion { get; }
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,27 @@
|
||||
using System;
|
||||
|
||||
namespace TrashLib.Sonarr
|
||||
{
|
||||
public record SonarrCapabilities
|
||||
{
|
||||
public SonarrCapabilities()
|
||||
{
|
||||
Version = new Version();
|
||||
}
|
||||
|
||||
public SonarrCapabilities(Version version)
|
||||
{
|
||||
Version = version;
|
||||
}
|
||||
|
||||
public Version Version { get; }
|
||||
|
||||
public bool SupportsNamedReleaseProfiles { get; init; }
|
||||
|
||||
// Background: Issue #16 filed which points to a backward-breaking API
|
||||
// change made in Sonarr at commit [deed85d2f].
|
||||
//
|
||||
// [deed85d2f]: https://github.com/Sonarr/Sonarr/commit/deed85d2f9147e6180014507ef4f5af3695b0c61
|
||||
public bool ArraysNeededForReleaseProfileRequiredAndIgnored { get; init; }
|
||||
}
|
||||
}
|
Loading…
Reference in new issue