mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
Let IDalamudPluginInterface inherit from IServiceProvider
This commit is contained in:
parent
05f31265eb
commit
7ec1de4c76
3 changed files with 15 additions and 5 deletions
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Concurrent;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
|
|
@ -12,7 +12,7 @@ namespace Dalamud.IoC.Internal;
|
|||
/// <summary>
|
||||
/// Container enabling the creation of scoped services.
|
||||
/// </summary>
|
||||
internal interface IServiceScope : IAsyncDisposable
|
||||
internal interface IServiceScope : IServiceProvider, IAsyncDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Register objects that may be injected to scoped services,
|
||||
|
|
@ -57,6 +57,12 @@ internal class ServiceScopeImpl : IServiceScope
|
|||
/// <param name="container">The container this scope will use to create services.</param>
|
||||
public ServiceScopeImpl(ServiceContainer container) => this.container = container;
|
||||
|
||||
/// <inheritdoc/>
|
||||
object? IServiceProvider.GetService(Type serviceType)
|
||||
{
|
||||
return ((IServiceProvider)this.container).GetService(serviceType);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void RegisterPrivateScopes(params object[] scopes)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -454,6 +454,12 @@ internal sealed class DalamudPluginInterface : IDalamudPluginInterface, IDisposa
|
|||
|
||||
#region Dependency Injection
|
||||
|
||||
/// <inheritdoc/>
|
||||
public object? GetService(Type serviceType)
|
||||
{
|
||||
return this.plugin.ServiceScope.GetService(serviceType);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public T? Create<T>(params object[] scopedObjects) where T : class
|
||||
{
|
||||
|
|
|
|||
|
|
@ -8,8 +8,6 @@ using System.Threading.Tasks;
|
|||
using Dalamud.Configuration;
|
||||
using Dalamud.Game.Text;
|
||||
using Dalamud.Game.Text.Sanitizer;
|
||||
using Dalamud.Game.Text.SeStringHandling;
|
||||
using Dalamud.Game.Text.SeStringHandling.Payloads;
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Interface.Internal.Windows.PluginInstaller;
|
||||
using Dalamud.Interface.Internal.Windows.Settings;
|
||||
|
|
@ -24,7 +22,7 @@ namespace Dalamud.Plugin;
|
|||
/// <summary>
|
||||
/// This interface acts as an interface to various objects needed to interact with Dalamud and the game.
|
||||
/// </summary>
|
||||
public interface IDalamudPluginInterface
|
||||
public interface IDalamudPluginInterface : IServiceProvider
|
||||
{
|
||||
/// <summary>
|
||||
/// Delegate for localization change with two-letter iso lang code.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue