mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-15 05:04:15 +01:00
Use external library for API interface and IPC.
This commit is contained in:
parent
b3f048bfe6
commit
918d5db6a6
69 changed files with 4026 additions and 1873 deletions
66
tmp/Helpers/ActionProvider.cs
Normal file
66
tmp/Helpers/ActionProvider.cs
Normal 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();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue