Use external library for API interface and IPC.

This commit is contained in:
Ottermandias 2022-10-08 02:02:33 +02:00
parent b3f048bfe6
commit 918d5db6a6
69 changed files with 4026 additions and 1873 deletions

View file

@ -0,0 +1,66 @@
using System;
using Dalamud.Logging;
using Dalamud.Plugin;
using Dalamud.Plugin.Ipc;
namespace Penumbra.Api.Helpers;
public sealed class ActionProvider<T1> : IDisposable
{
private ICallGateProvider<T1, object?>? _provider;
public ActionProvider( DalamudPluginInterface pi, string label, Action<T1> action )
{
try
{
_provider = pi.GetIpcProvider<T1, object?>( label );
}
catch( Exception e )
{
PluginLog.Error( $"Error registering IPC Provider for {label}\n{e}" );
_provider = null;
}
_provider?.RegisterAction( action );
}
public void Dispose()
{
_provider?.UnregisterAction();
_provider = null;
GC.SuppressFinalize( this );
}
~ActionProvider()
=> Dispose();
}
public sealed class ActionProvider< T1, T2 > : IDisposable
{
private ICallGateProvider< T1, T2, object? >? _provider;
public ActionProvider( DalamudPluginInterface pi, string label, Action< T1, T2 > action )
{
try
{
_provider = pi.GetIpcProvider< T1, T2, object? >( label );
}
catch( Exception e )
{
PluginLog.Error( $"Error registering IPC Provider for {label}\n{e}" );
_provider = null;
}
_provider?.RegisterAction( action );
}
public void Dispose()
{
_provider?.UnregisterAction();
_provider = null;
GC.SuppressFinalize( this );
}
~ActionProvider()
=> Dispose();
}