- Fixed stack ovewrflow from ServicesProvider (???).
This commit is contained in:
@@ -330,7 +330,11 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (!PackageManagementService.IsAnyPackageRunning())
|
if (!PackageManagementService.IsAnyPackageRunning())
|
||||||
{
|
{
|
||||||
Logger.LogResults(PackageManagementService.ExecuteLoadedPackages(ContentPackageManager.EnabledPackages.All.ToImmutableArray()));
|
#if DEBUG
|
||||||
|
Logger.LogResults(PackageManagementService.ExecuteLoadedPackages(ContentPackageManager.EnabledPackages.All.ToImmutableArray(), true));
|
||||||
|
#else
|
||||||
|
Logger.LogResults(PackageManagementService.ExecuteLoadedPackages(ContentPackageManager.EnabledPackages.All.ToImmutableArray(), IsCsEnabled));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
CurrentRunState = RunState.Running;
|
CurrentRunState = RunState.Running;
|
||||||
|
|||||||
@@ -189,7 +189,7 @@ public sealed class PackageManagementService : IPackageManagementService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public FluentResults.Result ExecuteLoadedPackages(ImmutableArray<ContentPackage> executionOrder)
|
public FluentResults.Result ExecuteLoadedPackages(ImmutableArray<ContentPackage> executionOrder, bool executeCsAssemblies)
|
||||||
{
|
{
|
||||||
using var lck = _operationsLock.AcquireReaderLock().ConfigureAwait(false).GetAwaiter().GetResult();
|
using var lck = _operationsLock.AcquireReaderLock().ConfigureAwait(false).GetAwaiter().GetResult();
|
||||||
using var executeLock = _executionLock.AcquireWriterLock().ConfigureAwait(false).GetAwaiter().GetResult();
|
using var executeLock = _executionLock.AcquireWriterLock().ConfigureAwait(false).GetAwaiter().GetResult();
|
||||||
@@ -237,7 +237,7 @@ public sealed class PackageManagementService : IPackageManagementService
|
|||||||
result.WithReasons(_luaScriptManagementService.ExecuteLoadedScripts(luaScripts).Reasons);
|
result.WithReasons(_luaScriptManagementService.ExecuteLoadedScripts(luaScripts).Reasons);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_runConfig.IsCsEnabled)
|
if (executeCsAssemblies)
|
||||||
{
|
{
|
||||||
var plugins = SelectCompatible(loadingOrderedPackages
|
var plugins = SelectCompatible(loadingOrderedPackages
|
||||||
.SelectMany(pkg => pkg.Value.Assemblies)
|
.SelectMany(pkg => pkg.Value.Assemblies)
|
||||||
|
|||||||
+15
-19
@@ -99,13 +99,12 @@ public class PluginManagementService : IAssemblyManagementService
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private IServicesProvider _serviceProvider;
|
|
||||||
private IAssemblyLoaderService.IFactory _assemblyLoaderFactory;
|
private IAssemblyLoaderService.IFactory _assemblyLoaderFactory;
|
||||||
private IStorageService _storageService;
|
private IStorageService _storageService;
|
||||||
private ILoggerService _logger;
|
private ILoggerService _logger;
|
||||||
private IEventService _eventService;
|
private Lazy<IEventService> _eventService;
|
||||||
private IConfigService _configService;
|
private Lazy<IConfigService> _configService;
|
||||||
private ILuaScriptManagementService _luaScriptManagementService;
|
private Lazy<ILuaScriptManagementService> _luaScriptManagementService;
|
||||||
private readonly ConcurrentDictionary<ContentPackage, IAssemblyLoaderService> _assemblyLoaders = new();
|
private readonly ConcurrentDictionary<ContentPackage, IAssemblyLoaderService> _assemblyLoaders = new();
|
||||||
private readonly ConcurrentDictionary<ContentPackage, ImmutableArray<IAssemblyPlugin>> _pluginInstances = new();
|
private readonly ConcurrentDictionary<ContentPackage, ImmutableArray<IAssemblyPlugin>> _pluginInstances = new();
|
||||||
private readonly ConditionalWeakTable<IAssemblyLoaderService, ContentPackage> _unloadingAssemblyLoaders = new();
|
private readonly ConditionalWeakTable<IAssemblyLoaderService, ContentPackage> _unloadingAssemblyLoaders = new();
|
||||||
@@ -113,16 +112,13 @@ public class PluginManagementService : IAssemblyManagementService
|
|||||||
private ServiceContainer _pluginInjectorContainer;
|
private ServiceContainer _pluginInjectorContainer;
|
||||||
|
|
||||||
public PluginManagementService(
|
public PluginManagementService(
|
||||||
IServicesProvider serviceProvider,
|
|
||||||
IAssemblyLoaderService.IFactory assemblyLoaderFactory,
|
IAssemblyLoaderService.IFactory assemblyLoaderFactory,
|
||||||
IStorageService storageService,
|
IStorageService storageService,
|
||||||
ILoggerService logger,
|
ILoggerService logger,
|
||||||
IEventService eventService,
|
Lazy<IEventService> eventService,
|
||||||
ILuaScriptManagementService luaScriptManagementService,
|
Lazy<ILuaScriptManagementService> luaScriptManagementService,
|
||||||
IConfigService configService)
|
Lazy<IConfigService> configService)
|
||||||
{
|
{
|
||||||
Guard.IsNotNull(serviceProvider, nameof(serviceProvider));
|
|
||||||
_serviceProvider = serviceProvider;
|
|
||||||
_assemblyLoaderFactory = assemblyLoaderFactory;
|
_assemblyLoaderFactory = assemblyLoaderFactory;
|
||||||
_storageService = storageService;
|
_storageService = storageService;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
@@ -139,11 +135,11 @@ public class PluginManagementService : IAssemblyManagementService
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
container.Register<ILoggerService>(fac => _logger, new PerContainerLifetime());
|
container.Register<ILoggerService>(fac => _logger);
|
||||||
container.Register<IStorageService>(fac => _storageService, new PerContainerLifetime());
|
container.Register<IStorageService>(fac => _storageService);
|
||||||
container.Register<IEventService>(fac => _eventService, new PerContainerLifetime());
|
container.Register<IEventService>(fac => _eventService.Value);
|
||||||
container.Register<ILuaScriptManagementService>(fac => _luaScriptManagementService, new PerContainerLifetime());
|
container.Register<ILuaScriptManagementService>(fac => _luaScriptManagementService.Value);
|
||||||
container.Register<IConfigService>(fac => _configService, new PerContainerLifetime());
|
container.Register<IConfigService>(fac => _configService.Value);
|
||||||
|
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
@@ -268,21 +264,21 @@ public class PluginManagementService : IAssemblyManagementService
|
|||||||
results.WithReasons(PluginInitRunner(plugin, p => p.PreInitPatching()).Reasons);
|
results.WithReasons(PluginInitRunner(plugin, p => p.PreInitPatching()).Reasons);
|
||||||
}
|
}
|
||||||
|
|
||||||
_eventService.PublishEvent<IEventPluginPreInitialize>(sub => sub.PreInitPatching());
|
_eventService.Value.PublishEvent<IEventPluginPreInitialize>(sub => sub.PreInitPatching());
|
||||||
|
|
||||||
foreach (var plugin in pluginsToInit)
|
foreach (var plugin in pluginsToInit)
|
||||||
{
|
{
|
||||||
results.WithReasons(PluginInitRunner(plugin, p => p.Initialize()).Reasons);
|
results.WithReasons(PluginInitRunner(plugin, p => p.Initialize()).Reasons);
|
||||||
}
|
}
|
||||||
|
|
||||||
_eventService.PublishEvent<IEventPluginInitialize>(sub => sub.Initialize());
|
_eventService.Value.PublishEvent<IEventPluginInitialize>(sub => sub.Initialize());
|
||||||
|
|
||||||
foreach (var plugin in pluginsToInit)
|
foreach (var plugin in pluginsToInit)
|
||||||
{
|
{
|
||||||
results.WithReasons(PluginInitRunner(plugin, p => p.OnLoadCompleted()).Reasons);
|
results.WithReasons(PluginInitRunner(plugin, p => p.OnLoadCompleted()).Reasons);
|
||||||
}
|
}
|
||||||
|
|
||||||
_eventService.PublishEvent<IEventPluginLoadCompleted>(sub => sub.OnLoadCompleted());
|
_eventService.Value.PublishEvent<IEventPluginLoadCompleted>(sub => sub.OnLoadCompleted());
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
|
|
||||||
@@ -527,7 +523,7 @@ public class PluginManagementService : IAssemblyManagementService
|
|||||||
|
|
||||||
foreach (var assembly in loader.Assemblies)
|
foreach (var assembly in loader.Assemblies)
|
||||||
{
|
{
|
||||||
_eventService.PublishEvent<IEventAssemblyUnloading>(sub => sub.OnAssemblyUnloading(assembly));
|
_eventService.Value.PublishEvent<IEventAssemblyUnloading>(sub => sub.OnAssemblyUnloading(assembly));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ public class ServicesProvider : IServicesProvider
|
|||||||
EnablePropertyInjection = false
|
EnablePropertyInjection = false
|
||||||
});
|
});
|
||||||
|
|
||||||
_serviceContainerInst.Register<IServicesProvider>((f) => this);
|
//_serviceContainerInst.Register<IServicesProvider>((f) => this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RegisterServiceType<TSvcInterface, TService>(ServiceLifetime lifetime, ILifetime lifetimeInstance = null) where TSvcInterface : class, IService where TService : class, IService, TSvcInterface
|
public void RegisterServiceType<TSvcInterface, TService>(ServiceLifetime lifetime, ILifetime lifetimeInstance = null) where TSvcInterface : class, IService where TService : class, IService, TSvcInterface
|
||||||
|
|||||||
+1
-1
@@ -14,7 +14,7 @@ public interface IPackageManagementService : IReusableService
|
|||||||
{
|
{
|
||||||
public FluentResults.Result LoadPackageInfo(ContentPackage package);
|
public FluentResults.Result LoadPackageInfo(ContentPackage package);
|
||||||
public FluentResults.Result LoadPackagesInfo(ImmutableArray<ContentPackage> packages);
|
public FluentResults.Result LoadPackagesInfo(ImmutableArray<ContentPackage> packages);
|
||||||
public FluentResults.Result ExecuteLoadedPackages(ImmutableArray<ContentPackage> executionOrder);
|
public FluentResults.Result ExecuteLoadedPackages(ImmutableArray<ContentPackage> executionOrder, bool executeCsAssemblies);
|
||||||
public FluentResults.Result SyncLoadedPackagesList(ImmutableArray<ContentPackage> packages);
|
public FluentResults.Result SyncLoadedPackagesList(ImmutableArray<ContentPackage> packages);
|
||||||
public FluentResults.Result StopRunningPackages();
|
public FluentResults.Result StopRunningPackages();
|
||||||
public FluentResults.Result UnloadPackage(ContentPackage package);
|
public FluentResults.Result UnloadPackage(ContentPackage package);
|
||||||
|
|||||||
Reference in New Issue
Block a user