Interface support for plugin DI (#1235)

* feat: interface support for plugin DI
* attribute to indicate resolvability should be on the service instead of the interface
This commit is contained in:
goat 2023-06-13 20:10:47 +02:00 committed by GitHub
parent 7eb05ddae2
commit 284001ce6b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 69 additions and 11 deletions

View file

@ -3,6 +3,7 @@ using System.Collections.Generic;
using Dalamud.IoC;
using Dalamud.IoC.Internal;
using Dalamud.Plugin.Services;
using FFXIVClientStructs.FFXIV.Client.Game.UI;
using Serilog;
@ -14,7 +15,8 @@ namespace Dalamud.Game.ClientState.Aetherytes;
[PluginInterface]
[InterfaceVersion("1.0")]
[ServiceManager.BlockingEarlyLoadedService]
public sealed unsafe partial class AetheryteList : IServiceType
[ResolveVia<IAetheryteList>]
public sealed unsafe partial class AetheryteList : IServiceType, IAetheryteList
{
[ServiceManager.ServiceDependency]
private readonly ClientState clientState = Service<ClientState>.Get();
@ -27,9 +29,7 @@ public sealed unsafe partial class AetheryteList : IServiceType
Log.Verbose($"Teleport address 0x{((nint)this.telepoInstance).ToInt64():X}");
}
/// <summary>
/// Gets the amount of Aetherytes the local player has unlocked.
/// </summary>
/// <inheritdoc/>
public int Length
{
get
@ -46,11 +46,7 @@ public sealed unsafe partial class AetheryteList : IServiceType
}
}
/// <summary>
/// Gets a Aetheryte Entry at the specified index.
/// </summary>
/// <param name="index">Index.</param>
/// <returns>A <see cref="AetheryteEntry"/> at the specified index.</returns>
/// <inheritdoc/>
public AetheryteEntry? this[int index]
{
get
@ -80,7 +76,7 @@ public sealed unsafe partial class AetheryteList : IServiceType
/// <summary>
/// This collection represents the list of available Aetherytes in the Teleport window.
/// </summary>
public sealed partial class AetheryteList : IReadOnlyCollection<AetheryteEntry>
public sealed partial class AetheryteList
{
/// <inheritdoc/>
public int Count => this.Length;