Fixed ConfigService not filtering out configs that it shouldn't be loading.
This commit is contained in:
@@ -292,7 +292,6 @@ public sealed partial class ConfigService : IConfigService
|
|||||||
}, false);
|
}, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void RegisterSettingTypeInitializer<T>(string typeIdentifier, Func<(IConfigService ConfigService, IConfigInfo Info), T> settingFactory) where T : class, ISettingBase
|
public void RegisterSettingTypeInitializer<T>(string typeIdentifier, Func<(IConfigService ConfigService, IConfigInfo Info), T> settingFactory) where T : class, ISettingBase
|
||||||
{
|
{
|
||||||
Guard.IsNotNullOrWhiteSpace(typeIdentifier, nameof(typeIdentifier));
|
Guard.IsNotNullOrWhiteSpace(typeIdentifier, nameof(typeIdentifier));
|
||||||
@@ -308,6 +307,16 @@ public sealed partial class ConfigService : IConfigService
|
|||||||
_instanceFactory[typeIdentifier] = settingFactory;
|
_instanceFactory[typeIdentifier] = settingFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static ImmutableArray<T> SelectCompatible<T>(ImmutableArray<T> resources) where T : IBaseResourceInfo
|
||||||
|
{
|
||||||
|
return resources
|
||||||
|
.Where(r => r.SupportedPlatforms.HasFlag(ModUtils.Environment.CurrentPlatform))
|
||||||
|
.Where(r => r.SupportedTargets.HasFlag(ModUtils.Environment.CurrentTarget))
|
||||||
|
.OrderBy(r => r.Optional ? 1 : 0) // optional content last
|
||||||
|
.ThenBy(r => r.LoadPriority)
|
||||||
|
.ToImmutableArray();
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<FluentResults.Result> LoadConfigsAsync(ImmutableArray<IConfigResourceInfo> configResources)
|
public async Task<FluentResults.Result> LoadConfigsAsync(ImmutableArray<IConfigResourceInfo> configResources)
|
||||||
{
|
{
|
||||||
using var lck = await _operationLock.AcquireReaderLock();
|
using var lck = await _operationLock.AcquireReaderLock();
|
||||||
@@ -320,7 +329,7 @@ public sealed partial class ConfigService : IConfigService
|
|||||||
var taskBuilder = ImmutableArray.CreateBuilder<Task<ImmutableArray<IConfigInfo>>>();
|
var taskBuilder = ImmutableArray.CreateBuilder<Task<ImmutableArray<IConfigInfo>>>();
|
||||||
var toProcessErrors = new ConcurrentStack<IError>();
|
var toProcessErrors = new ConcurrentStack<IError>();
|
||||||
|
|
||||||
foreach (var resource in configResources)
|
foreach (var resource in SelectCompatible(configResources))
|
||||||
{
|
{
|
||||||
taskBuilder.Add(await Task.Factory.StartNew<Task<ImmutableArray<IConfigInfo>>>(async Task<ImmutableArray<IConfigInfo>> () =>
|
taskBuilder.Add(await Task.Factory.StartNew<Task<ImmutableArray<IConfigInfo>>>(async Task<ImmutableArray<IConfigInfo>> () =>
|
||||||
{
|
{
|
||||||
@@ -408,7 +417,7 @@ public sealed partial class ConfigService : IConfigService
|
|||||||
|
|
||||||
var result = new FluentResults.Result();
|
var result = new FluentResults.Result();
|
||||||
|
|
||||||
foreach (var resource in configProfileResources)
|
foreach (var resource in SelectCompatible(configProfileResources))
|
||||||
{
|
{
|
||||||
var r = await _configProfileInfoParserService.TryParseResourcesAsync(resource);
|
var r = await _configProfileInfoParserService.TryParseResourcesAsync(resource);
|
||||||
if (r.IsFailed)
|
if (r.IsFailed)
|
||||||
|
|||||||
Reference in New Issue
Block a user