From a725bbf8e06c093d16aee3036551c242d48c7e11 Mon Sep 17 00:00:00 2001 From: Soreepeong Date: Wed, 24 Jul 2024 19:20:39 +0900 Subject: [PATCH] cleanup --- Dalamud/IoC/Internal/ServiceContainer.cs | 2 +- Dalamud/IoC/Internal/ServiceScope.cs | 27 ++++++++--------------- Dalamud/Plugin/DalamudPluginInterface.cs | 4 ++-- Dalamud/Plugin/IDalamudPluginInterface.cs | 4 ++-- 4 files changed, 14 insertions(+), 23 deletions(-) diff --git a/Dalamud/IoC/Internal/ServiceContainer.cs b/Dalamud/IoC/Internal/ServiceContainer.cs index 39c2007f3..a8eacb02d 100644 --- a/Dalamud/IoC/Internal/ServiceContainer.cs +++ b/Dalamud/IoC/Internal/ServiceContainer.cs @@ -145,7 +145,7 @@ internal class ServiceContainer : IServiceProvider, IServiceType /// Scoped objects to be injected. /// The scope to be used to create scoped services. /// A representing the operation. - public async ValueTask InjectProperties(object instance, object[] publicScopes, IServiceScope? scope = null) + public async Task InjectProperties(object instance, object[] publicScopes, IServiceScope? scope = null) { var scopeImpl = scope as ServiceScopeImpl; var objectType = instance.GetType(); diff --git a/Dalamud/IoC/Internal/ServiceScope.cs b/Dalamud/IoC/Internal/ServiceScope.cs index fb06ec75c..4fc299f6e 100644 --- a/Dalamud/IoC/Internal/ServiceScope.cs +++ b/Dalamud/IoC/Internal/ServiceScope.cs @@ -17,7 +17,7 @@ internal interface IServiceScope : IDisposable /// but not directly to created objects. /// /// The scopes to add. - public void RegisterPrivateScopes(params object[] scopes); + void RegisterPrivateScopes(params object[] scopes); /// /// Create an object. @@ -25,7 +25,7 @@ internal interface IServiceScope : IDisposable /// The type of object to create. /// Scoped objects to be included in the constructor. /// The created object. - public Task CreateAsync(Type objectType, params object[] scopedObjects); + Task CreateAsync(Type objectType, params object[] scopedObjects); /// /// Inject interfaces into public or static properties on the provided object. @@ -34,7 +34,7 @@ internal interface IServiceScope : IDisposable /// The object instance. /// Scoped objects to be injected. /// A representing the status of the operation. - public ValueTask InjectPropertiesAsync(object instance, params object[] scopedObjects); + Task InjectPropertiesAsync(object instance, params object[] scopedObjects); } /// @@ -47,29 +47,20 @@ internal class ServiceScopeImpl : IServiceScope private readonly List privateScopedObjects = []; private readonly ConcurrentDictionary> scopeCreatedObjects = new(); - /// - /// Initializes a new instance of the class. - /// + /// Initializes a new instance of the class. /// The container this scope will use to create services. - public ServiceScopeImpl(ServiceContainer container) - { - this.container = container; - } + public ServiceScopeImpl(ServiceContainer container) => this.container = container; /// - public void RegisterPrivateScopes(params object[] scopes) - { + public void RegisterPrivateScopes(params object[] scopes) => this.privateScopedObjects.AddRange(scopes); - } /// - public Task CreateAsync(Type objectType, params object[] scopedObjects) - { - return this.container.CreateAsync(objectType, scopedObjects, this); - } + public Task CreateAsync(Type objectType, params object[] scopedObjects) => + this.container.CreateAsync(objectType, scopedObjects, this); /// - public ValueTask InjectPropertiesAsync(object instance, params object[] scopedObjects) => + public Task InjectPropertiesAsync(object instance, params object[] scopedObjects) => this.container.InjectProperties(instance, scopedObjects, this); /// diff --git a/Dalamud/Plugin/DalamudPluginInterface.cs b/Dalamud/Plugin/DalamudPluginInterface.cs index f0882c6fe..ecd2e0799 100644 --- a/Dalamud/Plugin/DalamudPluginInterface.cs +++ b/Dalamud/Plugin/DalamudPluginInterface.cs @@ -487,7 +487,7 @@ internal sealed class DalamudPluginInterface : IDalamudPluginInterface, IDisposa /// public bool Inject(object instance, params object[] scopedObjects) { - var t = this.InjectAsync(instance, scopedObjects).AsTask(); + var t = this.InjectAsync(instance, scopedObjects); t.Wait(); if (t.Exception is { } e) @@ -504,7 +504,7 @@ internal sealed class DalamudPluginInterface : IDalamudPluginInterface, IDisposa } /// - public ValueTask InjectAsync(object instance, params object[] scopedObjects) => + public Task InjectAsync(object instance, params object[] scopedObjects) => this.plugin.ServiceScope!.InjectPropertiesAsync(instance, this.GetPublicIocScopes(scopedObjects)); #endregion diff --git a/Dalamud/Plugin/IDalamudPluginInterface.cs b/Dalamud/Plugin/IDalamudPluginInterface.cs index 5205c3ed1..100d4570e 100644 --- a/Dalamud/Plugin/IDalamudPluginInterface.cs +++ b/Dalamud/Plugin/IDalamudPluginInterface.cs @@ -321,7 +321,7 @@ public interface IDalamudPluginInterface /// /// The instance to inject services into. /// Objects to inject additionally. - /// Whether or not the injection succeeded. + /// Whether the injection succeeded. bool Inject(object instance, params object[] scopedObjects); /// @@ -330,5 +330,5 @@ public interface IDalamudPluginInterface /// The instance to inject services into. /// Objects to inject additionally. /// A representing the status of the operation. - ValueTask InjectAsync(object instance, params object[] scopedObjects); + Task InjectAsync(object instance, params object[] scopedObjects); }