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