small startup performance optimization
This commit is contained in:
parent
73036dc1c7
commit
f4b160b735
@ -355,9 +355,9 @@ namespace IW4MAdmin.Application
|
|||||||
// copy over default config if it doesn't exist
|
// copy over default config if it doesn't exist
|
||||||
if (!_appConfig.Servers?.Any() ?? true)
|
if (!_appConfig.Servers?.Any() ?? true)
|
||||||
{
|
{
|
||||||
var defaultConfig = new BaseConfigurationHandler<DefaultSettings>("DefaultSettings").Configuration();
|
var defaultHandler = new BaseConfigurationHandler<DefaultSettings>("DefaultSettings");
|
||||||
//ConfigHandler.Set((ApplicationConfiguration)new ApplicationConfiguration().Generate());
|
await defaultHandler.BuildAsync();
|
||||||
//var newConfig = ConfigHandler.Configuration();
|
var defaultConfig = defaultHandler.Configuration();
|
||||||
|
|
||||||
_appConfig.AutoMessages = defaultConfig.AutoMessages;
|
_appConfig.AutoMessages = defaultConfig.AutoMessages;
|
||||||
_appConfig.GlobalRules = defaultConfig.GlobalRules;
|
_appConfig.GlobalRules = defaultConfig.GlobalRules;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using IW4MAdmin.Application.Misc;
|
using System.Threading.Tasks;
|
||||||
|
using IW4MAdmin.Application.Misc;
|
||||||
using SharedLibraryCore.Interfaces;
|
using SharedLibraryCore.Interfaces;
|
||||||
|
|
||||||
namespace IW4MAdmin.Application.Factories
|
namespace IW4MAdmin.Application.Factories
|
||||||
@ -17,7 +18,17 @@ namespace IW4MAdmin.Application.Factories
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public IConfigurationHandler<T> GetConfigurationHandler<T>(string name) where T : IBaseConfiguration
|
public IConfigurationHandler<T> GetConfigurationHandler<T>(string name) where T : IBaseConfiguration
|
||||||
{
|
{
|
||||||
return new BaseConfigurationHandler<T>(name);
|
var handler = new BaseConfigurationHandler<T>(name);
|
||||||
|
handler.BuildAsync().Wait();
|
||||||
|
return handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public async Task<IConfigurationHandler<T>> GetConfigurationHandlerAsync<T>(string name) where T : IBaseConfiguration
|
||||||
|
{
|
||||||
|
var handler = new BaseConfigurationHandler<T>(name);
|
||||||
|
await handler.BuildAsync();
|
||||||
|
return handler;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -355,7 +355,7 @@ namespace IW4MAdmin
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var factory = _serviceProvider.GetRequiredService<IDatabaseContextFactory>();
|
var factory = _serviceProvider.GetRequiredService<IDatabaseContextFactory>();
|
||||||
await using var context = factory.CreateContext();
|
await using var context = factory.CreateContext(enableTracking: false);
|
||||||
|
|
||||||
var messageCount = await context.InboxMessages
|
var messageCount = await context.InboxMessages
|
||||||
.CountAsync(msg => msg.DestinationClientId == E.Origin.ClientId && !msg.IsDelivered);
|
.CountAsync(msg => msg.DestinationClientId == E.Origin.ClientId && !msg.IsDelivered);
|
||||||
|
@ -341,7 +341,11 @@ namespace IW4MAdmin.Application
|
|||||||
// setup the static resources (config/master api/translations)
|
// setup the static resources (config/master api/translations)
|
||||||
var serviceCollection = new ServiceCollection();
|
var serviceCollection = new ServiceCollection();
|
||||||
var appConfigHandler = new BaseConfigurationHandler<ApplicationConfiguration>("IW4MAdminSettings");
|
var appConfigHandler = new BaseConfigurationHandler<ApplicationConfiguration>("IW4MAdminSettings");
|
||||||
|
await appConfigHandler.BuildAsync();
|
||||||
var defaultConfigHandler = new BaseConfigurationHandler<DefaultSettings>("DefaultSettings");
|
var defaultConfigHandler = new BaseConfigurationHandler<DefaultSettings>("DefaultSettings");
|
||||||
|
await defaultConfigHandler.BuildAsync();
|
||||||
|
var commandConfigHandler = new BaseConfigurationHandler<CommandConfiguration>("CommandConfiguration");
|
||||||
|
await commandConfigHandler.BuildAsync();
|
||||||
var defaultConfig = defaultConfigHandler.Configuration();
|
var defaultConfig = defaultConfigHandler.Configuration();
|
||||||
var appConfig = appConfigHandler.Configuration();
|
var appConfig = appConfigHandler.Configuration();
|
||||||
var masterUri = Utilities.IsDevelopment
|
var masterUri = Utilities.IsDevelopment
|
||||||
@ -380,9 +384,7 @@ namespace IW4MAdmin.Application
|
|||||||
.AddSingleton<IServiceCollection>(serviceCollection)
|
.AddSingleton<IServiceCollection>(serviceCollection)
|
||||||
.AddSingleton<IConfigurationHandler<DefaultSettings>, BaseConfigurationHandler<DefaultSettings>>()
|
.AddSingleton<IConfigurationHandler<DefaultSettings>, BaseConfigurationHandler<DefaultSettings>>()
|
||||||
.AddSingleton((IConfigurationHandler<ApplicationConfiguration>) appConfigHandler)
|
.AddSingleton((IConfigurationHandler<ApplicationConfiguration>) appConfigHandler)
|
||||||
.AddSingleton(
|
.AddSingleton<IConfigurationHandler<CommandConfiguration>>(commandConfigHandler)
|
||||||
new BaseConfigurationHandler<CommandConfiguration>("CommandConfiguration") as
|
|
||||||
IConfigurationHandler<CommandConfiguration>)
|
|
||||||
.AddSingleton(appConfig)
|
.AddSingleton(appConfig)
|
||||||
.AddSingleton(serviceProvider =>
|
.AddSingleton(serviceProvider =>
|
||||||
serviceProvider.GetRequiredService<IConfigurationHandler<CommandConfiguration>>()
|
serviceProvider.GetRequiredService<IConfigurationHandler<CommandConfiguration>>()
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
using Newtonsoft.Json;
|
using SharedLibraryCore;
|
||||||
using SharedLibraryCore;
|
|
||||||
using SharedLibraryCore.Exceptions;
|
using SharedLibraryCore.Exceptions;
|
||||||
using SharedLibraryCore.Interfaces;
|
using SharedLibraryCore.Interfaces;
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using JsonSerializer = System.Text.Json.JsonSerializer;
|
||||||
|
|
||||||
namespace IW4MAdmin.Application.Misc
|
namespace IW4MAdmin.Application.Misc
|
||||||
{
|
{
|
||||||
@ -15,19 +17,24 @@ namespace IW4MAdmin.Application.Misc
|
|||||||
/// <typeparam name="T">base configuration type</typeparam>
|
/// <typeparam name="T">base configuration type</typeparam>
|
||||||
public class BaseConfigurationHandler<T> : IConfigurationHandler<T> where T : IBaseConfiguration
|
public class BaseConfigurationHandler<T> : IConfigurationHandler<T> where T : IBaseConfiguration
|
||||||
{
|
{
|
||||||
T _configuration;
|
private T _configuration;
|
||||||
private readonly SemaphoreSlim _onSaving;
|
private readonly SemaphoreSlim _onSaving;
|
||||||
|
private readonly JsonSerializerOptions _serializerOptions;
|
||||||
|
|
||||||
public BaseConfigurationHandler(string fn)
|
|
||||||
|
public BaseConfigurationHandler(string fileName)
|
||||||
{
|
{
|
||||||
|
_serializerOptions = new JsonSerializerOptions
|
||||||
|
{
|
||||||
|
WriteIndented = true,
|
||||||
|
};
|
||||||
|
_serializerOptions.Converters.Add(new JsonStringEnumConverter());
|
||||||
_onSaving = new SemaphoreSlim(1, 1);
|
_onSaving = new SemaphoreSlim(1, 1);
|
||||||
FileName = Path.Join(Utilities.OperatingDirectory, "Configuration", $"{fn}.json");
|
FileName = Path.Join(Utilities.OperatingDirectory, "Configuration", $"{fileName}.json");
|
||||||
Build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaseConfigurationHandler() : this(typeof(T).Name)
|
public BaseConfigurationHandler() : this(typeof(T).Name)
|
||||||
{
|
{
|
||||||
_onSaving = new SemaphoreSlim(1, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
~BaseConfigurationHandler()
|
~BaseConfigurationHandler()
|
||||||
@ -37,12 +44,12 @@ namespace IW4MAdmin.Application.Misc
|
|||||||
|
|
||||||
public string FileName { get; }
|
public string FileName { get; }
|
||||||
|
|
||||||
public void Build()
|
public async Task BuildAsync()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var configContent = File.ReadAllText(FileName);
|
await using var fileStream = File.OpenRead(FileName);
|
||||||
_configuration = JsonConvert.DeserializeObject<T>(configContent);
|
_configuration = await JsonSerializer.DeserializeAsync<T>(fileStream, _serializerOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
catch (FileNotFoundException)
|
catch (FileNotFoundException)
|
||||||
@ -65,14 +72,9 @@ namespace IW4MAdmin.Application.Misc
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
await _onSaving.WaitAsync();
|
await _onSaving.WaitAsync();
|
||||||
var settings = new JsonSerializerSettings()
|
|
||||||
{
|
|
||||||
Formatting = Formatting.Indented
|
|
||||||
};
|
|
||||||
settings.Converters.Add(new Newtonsoft.Json.Converters.StringEnumConverter());
|
|
||||||
|
|
||||||
var appConfigJson = JsonConvert.SerializeObject(_configuration, settings);
|
await using var fileStream = File.OpenWrite(FileName);
|
||||||
await File.WriteAllTextAsync(FileName, appConfigJson);
|
await JsonSerializer.SerializeAsync(fileStream, _configuration, _serializerOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
finally
|
finally
|
||||||
|
@ -168,9 +168,6 @@ namespace IW4MAdmin.Application.Misc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_scriptEngine.SetValue("_configHandler", new ScriptPluginConfigurationWrapper(Name, _scriptEngine));
|
|
||||||
await OnLoadAsync(manager);
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (pluginObject.isParser)
|
if (pluginObject.isParser)
|
||||||
@ -181,6 +178,14 @@ namespace IW4MAdmin.Application.Misc
|
|||||||
manager.AdditionalEventParsers.Add(eventParser);
|
manager.AdditionalEventParsers.Add(eventParser);
|
||||||
manager.AdditionalRConParsers.Add(rconParser);
|
manager.AdditionalRConParsers.Add(rconParser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var configWrapper = new ScriptPluginConfigurationWrapper(Name, _scriptEngine);
|
||||||
|
await configWrapper.InitializeAsync();
|
||||||
|
_scriptEngine.SetValue("_configHandler", configWrapper);
|
||||||
|
await OnLoadAsync(manager);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
catch (RuntimeBinderException) { }
|
catch (RuntimeBinderException) { }
|
||||||
|
@ -12,19 +12,24 @@ namespace IW4MAdmin.Application.Misc
|
|||||||
public class ScriptPluginConfigurationWrapper
|
public class ScriptPluginConfigurationWrapper
|
||||||
{
|
{
|
||||||
private readonly BaseConfigurationHandler<ScriptPluginConfiguration> _handler;
|
private readonly BaseConfigurationHandler<ScriptPluginConfiguration> _handler;
|
||||||
private readonly ScriptPluginConfiguration _config;
|
private ScriptPluginConfiguration _config;
|
||||||
private readonly string _pluginName;
|
private readonly string _pluginName;
|
||||||
private readonly Engine _scriptEngine;
|
private readonly Engine _scriptEngine;
|
||||||
|
|
||||||
public ScriptPluginConfigurationWrapper(string pluginName, Engine scriptEngine)
|
public ScriptPluginConfigurationWrapper(string pluginName, Engine scriptEngine)
|
||||||
{
|
{
|
||||||
_handler = new BaseConfigurationHandler<ScriptPluginConfiguration>("ScriptPluginSettings");
|
_handler = new BaseConfigurationHandler<ScriptPluginConfiguration>("ScriptPluginSettings");
|
||||||
_config = _handler.Configuration() ??
|
|
||||||
(ScriptPluginConfiguration) new ScriptPluginConfiguration().Generate();
|
|
||||||
_pluginName = pluginName;
|
_pluginName = pluginName;
|
||||||
_scriptEngine = scriptEngine;
|
_scriptEngine = scriptEngine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task InitializeAsync()
|
||||||
|
{
|
||||||
|
await _handler.BuildAsync();
|
||||||
|
_config = _handler.Configuration() ??
|
||||||
|
(ScriptPluginConfiguration) new ScriptPluginConfiguration().Generate();
|
||||||
|
}
|
||||||
|
|
||||||
private static int? AsInteger(double d)
|
private static int? AsInteger(double d)
|
||||||
{
|
{
|
||||||
return int.TryParse(d.ToString(CultureInfo.InvariantCulture), out var parsed) ? parsed : (int?) null;
|
return int.TryParse(d.ToString(CultureInfo.InvariantCulture), out var parsed) ? parsed : (int?) null;
|
||||||
|
@ -23,7 +23,7 @@ namespace Data.Context
|
|||||||
{
|
{
|
||||||
var link = new EFAliasLink();
|
var link = new EFAliasLink();
|
||||||
|
|
||||||
context.Clients.Add(new EFClient()
|
context.Clients.Add(new EFClient
|
||||||
{
|
{
|
||||||
Active = false,
|
Active = false,
|
||||||
Connections = 0,
|
Connections = 0,
|
||||||
@ -33,7 +33,7 @@ namespace Data.Context
|
|||||||
Masked = true,
|
Masked = true,
|
||||||
NetworkId = 0,
|
NetworkId = 0,
|
||||||
AliasLink = link,
|
AliasLink = link,
|
||||||
CurrentAlias = new EFAlias()
|
CurrentAlias = new EFAlias
|
||||||
{
|
{
|
||||||
Link = link,
|
Link = link,
|
||||||
Active = true,
|
Active = true,
|
||||||
|
@ -102,7 +102,7 @@ namespace Data.Helpers
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await using var context = _contextFactory.CreateContext();
|
await using var context = _contextFactory.CreateContext(false);
|
||||||
_cachedItems = await context.Set<T>().ToDictionaryAsync(item => item.Id);
|
_cachedItems = await context.Set<T>().ToDictionaryAsync(item => item.Id);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.SyndicationFeed.ReaderWriter" Version="1.0.2" />
|
<PackageReference Include="Microsoft.SyndicationFeed.ReaderWriter" Version="1.0.2" />
|
||||||
<PackageReference Include="RaidMax.IW4MAdmin.SharedLibraryCore" Version="2022.1.25.2" PrivateAssets="All" />
|
<PackageReference Include="RaidMax.IW4MAdmin.SharedLibraryCore" Version="2022.1.28.1" PrivateAssets="All" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||||
|
@ -65,6 +65,7 @@ namespace AutomessageFeed
|
|||||||
|
|
||||||
public async Task OnLoadAsync(IManager manager)
|
public async Task OnLoadAsync(IManager manager)
|
||||||
{
|
{
|
||||||
|
await _configurationHandler.BuildAsync();
|
||||||
if (_configurationHandler.Configuration() == null)
|
if (_configurationHandler.Configuration() == null)
|
||||||
{
|
{
|
||||||
_configurationHandler.Set((Configuration)new Configuration().Generate());
|
_configurationHandler.Set((Configuration)new Configuration().Generate());
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="RaidMax.IW4MAdmin.SharedLibraryCore" Version="2022.1.25.2" PrivateAssets="All" />
|
<PackageReference Include="RaidMax.IW4MAdmin.SharedLibraryCore" Version="2022.1.28.1" PrivateAssets="All" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||||
|
@ -1,29 +1,25 @@
|
|||||||
using LiveRadar.Configuration;
|
using LiveRadar.Configuration;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Newtonsoft.Json;
|
|
||||||
using SharedLibraryCore;
|
using SharedLibraryCore;
|
||||||
using SharedLibraryCore.Dtos;
|
using SharedLibraryCore.Dtos;
|
||||||
using SharedLibraryCore.Interfaces;
|
using SharedLibraryCore.Interfaces;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
|
|
||||||
namespace LiveRadar.Web.Controllers
|
namespace LiveRadar.Web.Controllers
|
||||||
{
|
{
|
||||||
public class RadarController : BaseController
|
public class RadarController : BaseController
|
||||||
{
|
{
|
||||||
private static readonly JsonSerializerSettings _serializerSettings = new JsonSerializerSettings()
|
|
||||||
{
|
|
||||||
ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
|
|
||||||
ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver()
|
|
||||||
};
|
|
||||||
|
|
||||||
private readonly IManager _manager;
|
private readonly IManager _manager;
|
||||||
private readonly LiveRadarConfiguration _config;
|
private static LiveRadarConfiguration _config;
|
||||||
|
private readonly IConfigurationHandler<LiveRadarConfiguration> _configurationHandler;
|
||||||
|
|
||||||
public RadarController(IManager manager, IConfigurationHandlerFactory configurationHandlerFactory) : base(manager)
|
public RadarController(IManager manager, IConfigurationHandlerFactory configurationHandlerFactory) : base(manager)
|
||||||
{
|
{
|
||||||
_manager = manager;
|
_manager = manager;
|
||||||
_config = configurationHandlerFactory.GetConfigurationHandler<LiveRadarConfiguration>("LiveRadarConfiguration").Configuration() ?? new LiveRadarConfiguration();
|
_configurationHandler =
|
||||||
|
configurationHandlerFactory.GetConfigurationHandler<LiveRadarConfiguration>("LiveRadarConfiguration");
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
@ -46,7 +42,7 @@ namespace LiveRadar.Web.Controllers
|
|||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Route("Radar/{serverId}/Map")]
|
[Route("Radar/{serverId}/Map")]
|
||||||
public IActionResult Map(long? serverId = null)
|
public async Task<IActionResult> Map(long? serverId = null)
|
||||||
{
|
{
|
||||||
var server = serverId == null ? _manager.GetServers().FirstOrDefault() : _manager.GetServers().FirstOrDefault(_server => _server.EndPoint == serverId);
|
var server = serverId == null ? _manager.GetServers().FirstOrDefault() : _manager.GetServers().FirstOrDefault(_server => _server.EndPoint == serverId);
|
||||||
|
|
||||||
@ -55,6 +51,12 @@ namespace LiveRadar.Web.Controllers
|
|||||||
return NotFound();
|
return NotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_config == null)
|
||||||
|
{
|
||||||
|
await _configurationHandler.BuildAsync();
|
||||||
|
_config = _configurationHandler.Configuration() ?? new LiveRadarConfiguration();
|
||||||
|
}
|
||||||
|
|
||||||
var map = _config.Maps.FirstOrDefault(_map => _map.Name == server.CurrentMap.Name);
|
var map = _config.Maps.FirstOrDefault(_map => _map.Name == server.CurrentMap.Name);
|
||||||
|
|
||||||
if (map == null)
|
if (map == null)
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="RaidMax.IW4MAdmin.SharedLibraryCore" Version="2022.1.25.2" PrivateAssets="All" />
|
<PackageReference Include="RaidMax.IW4MAdmin.SharedLibraryCore" Version="2022.1.28.1" PrivateAssets="All" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||||
|
@ -103,6 +103,7 @@ namespace LiveRadar
|
|||||||
|
|
||||||
public async Task OnLoadAsync(IManager manager)
|
public async Task OnLoadAsync(IManager manager)
|
||||||
{
|
{
|
||||||
|
await _configurationHandler.BuildAsync();
|
||||||
if (_configurationHandler.Configuration() == null)
|
if (_configurationHandler.Configuration() == null)
|
||||||
{
|
{
|
||||||
_configurationHandler.Set((LiveRadarConfiguration)new LiveRadarConfiguration().Generate());
|
_configurationHandler.Set((LiveRadarConfiguration)new LiveRadarConfiguration().Generate());
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="RaidMax.IW4MAdmin.SharedLibraryCore" Version="2022.1.25.2" PrivateAssets="All" />
|
<PackageReference Include="RaidMax.IW4MAdmin.SharedLibraryCore" Version="2022.1.28.1" PrivateAssets="All" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||||
|
@ -76,6 +76,7 @@ namespace IW4MAdmin.Plugins.Login
|
|||||||
{
|
{
|
||||||
AuthorizedClients = new ConcurrentDictionary<int, bool>();
|
AuthorizedClients = new ConcurrentDictionary<int, bool>();
|
||||||
|
|
||||||
|
await _configHandler.BuildAsync();
|
||||||
if (_configHandler.Configuration() == null)
|
if (_configHandler.Configuration() == null)
|
||||||
{
|
{
|
||||||
_configHandler.Set((Configuration)new Configuration().Generate());
|
_configHandler.Set((Configuration)new Configuration().Generate());
|
||||||
|
@ -109,6 +109,7 @@ namespace IW4MAdmin.Plugins.ProfanityDeterment
|
|||||||
|
|
||||||
public async Task OnLoadAsync(IManager manager)
|
public async Task OnLoadAsync(IManager manager)
|
||||||
{
|
{
|
||||||
|
await _configHandler.BuildAsync();
|
||||||
if (_configHandler.Configuration() == null)
|
if (_configHandler.Configuration() == null)
|
||||||
{
|
{
|
||||||
_configHandler.Set((Configuration)new Configuration().Generate());
|
_configHandler.Set((Configuration)new Configuration().Generate());
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="RaidMax.IW4MAdmin.SharedLibraryCore" Version="2022.1.25.2" PrivateAssets="All" />
|
<PackageReference Include="RaidMax.IW4MAdmin.SharedLibraryCore" Version="2022.1.28.1" PrivateAssets="All" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||||
|
@ -48,6 +48,7 @@ namespace Stats.Client
|
|||||||
await LoadServers();
|
await LoadServers();
|
||||||
_distributionCache.SetCacheItem((async (set, token) =>
|
_distributionCache.SetCacheItem((async (set, token) =>
|
||||||
{
|
{
|
||||||
|
await _configurationHandler.BuildAsync();
|
||||||
var validPlayTime = _configurationHandler.Configuration()?.TopPlayersMinPlayTime ?? 3600 * 3;
|
var validPlayTime = _configurationHandler.Configuration()?.TopPlayersMinPlayTime ?? 3600 * 3;
|
||||||
|
|
||||||
var distributions = new Dictionary<long, Extensions.LogParams>();
|
var distributions = new Dictionary<long, Extensions.LogParams>();
|
||||||
@ -73,6 +74,7 @@ namespace Stats.Client
|
|||||||
|
|
||||||
_maxZScoreCache.SetCacheItem(async (set, token) =>
|
_maxZScoreCache.SetCacheItem(async (set, token) =>
|
||||||
{
|
{
|
||||||
|
await _configurationHandler.BuildAsync();
|
||||||
var validPlayTime = _configurationHandler.Configuration()?.TopPlayersMinPlayTime ?? 3600 * 3;
|
var validPlayTime = _configurationHandler.Configuration()?.TopPlayersMinPlayTime ?? 3600 * 3;
|
||||||
|
|
||||||
var zScore = await set
|
var zScore = await set
|
||||||
|
@ -172,6 +172,7 @@ namespace IW4MAdmin.Plugins.Stats
|
|||||||
|
|
||||||
public async Task OnLoadAsync(IManager manager)
|
public async Task OnLoadAsync(IManager manager)
|
||||||
{
|
{
|
||||||
|
await Config.BuildAsync();
|
||||||
// load custom configuration
|
// load custom configuration
|
||||||
if (Config.Configuration() == null)
|
if (Config.Configuration() == null)
|
||||||
{
|
{
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="RaidMax.IW4MAdmin.SharedLibraryCore" Version="2022.1.25.2" PrivateAssets="All" />
|
<PackageReference Include="RaidMax.IW4MAdmin.SharedLibraryCore" Version="2022.1.28.1" PrivateAssets="All" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||||
|
@ -35,6 +35,7 @@ namespace IW4MAdmin.Plugins.Welcome
|
|||||||
|
|
||||||
public async Task OnLoadAsync(IManager manager)
|
public async Task OnLoadAsync(IManager manager)
|
||||||
{
|
{
|
||||||
|
await _configHandler.BuildAsync();
|
||||||
if (_configHandler.Configuration() == null)
|
if (_configHandler.Configuration() == null)
|
||||||
{
|
{
|
||||||
_configHandler.Set((WelcomeConfiguration) new WelcomeConfiguration().Generate());
|
_configHandler.Set((WelcomeConfiguration) new WelcomeConfiguration().Generate());
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="RaidMax.IW4MAdmin.SharedLibraryCore" Version="2022.1.25.2" PrivateAssets="All" />
|
<PackageReference Include="RaidMax.IW4MAdmin.SharedLibraryCore" Version="2022.1.28.1" PrivateAssets="All" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -6,7 +6,7 @@ namespace SharedLibraryCore.Interfaces
|
|||||||
{
|
{
|
||||||
string FileName { get; }
|
string FileName { get; }
|
||||||
Task Save();
|
Task Save();
|
||||||
void Build();
|
Task BuildAsync();
|
||||||
T Configuration();
|
T Configuration();
|
||||||
void Set(T config);
|
void Set(T config);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
namespace SharedLibraryCore.Interfaces
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SharedLibraryCore.Interfaces
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// defines the capabilities of the configuration handler factory
|
/// defines the capabilities of the configuration handler factory
|
||||||
@ -13,5 +15,13 @@
|
|||||||
/// <param name="name">file name of configuration</param>
|
/// <param name="name">file name of configuration</param>
|
||||||
/// <returns>new configuration handler instance</returns>
|
/// <returns>new configuration handler instance</returns>
|
||||||
IConfigurationHandler<T> GetConfigurationHandler<T>(string name) where T : IBaseConfiguration;
|
IConfigurationHandler<T> GetConfigurationHandler<T>(string name) where T : IBaseConfiguration;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// generates a new configuration handler and builds the configuration automatically
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">base configuration type</typeparam>
|
||||||
|
/// <param name="name">file name of configuration</param>
|
||||||
|
/// <returns>new configuration handler instance</returns>
|
||||||
|
Task<IConfigurationHandler<T>> GetConfigurationHandlerAsync<T>(string name) where T : IBaseConfiguration;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,7 +4,7 @@
|
|||||||
<OutputType>Library</OutputType>
|
<OutputType>Library</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<PackageId>RaidMax.IW4MAdmin.SharedLibraryCore</PackageId>
|
<PackageId>RaidMax.IW4MAdmin.SharedLibraryCore</PackageId>
|
||||||
<Version>2022.01.25.2</Version>
|
<Version>2022.01.28.1</Version>
|
||||||
<Authors>RaidMax</Authors>
|
<Authors>RaidMax</Authors>
|
||||||
<Company>Forever None</Company>
|
<Company>Forever None</Company>
|
||||||
<Configurations>Debug;Release;Prerelease</Configurations>
|
<Configurations>Debug;Release;Prerelease</Configurations>
|
||||||
@ -19,7 +19,7 @@
|
|||||||
<IsPackable>true</IsPackable>
|
<IsPackable>true</IsPackable>
|
||||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||||
<Description>Shared Library for IW4MAdmin</Description>
|
<Description>Shared Library for IW4MAdmin</Description>
|
||||||
<PackageVersion>2022.01.25.2</PackageVersion>
|
<PackageVersion>2022.01.28.1</PackageVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Prerelease|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Prerelease|AnyCPU'">
|
||||||
|
Loading…
Reference in New Issue
Block a user