diff --git a/.gitignore b/.gitignore
index edbc2eec0..8f7e6f1cc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -241,3 +241,4 @@ launchSettings.json
/WebfrontCore/wwwroot/fonts
/WebfrontCore/wwwroot/font
/Plugins/Tests/TestSourceFiles
+/Tests/ApplicationTests/Files/GameEvents.json
diff --git a/Application/Application.csproj b/Application/Application.csproj
index e68fb48f0..4f37f0940 100644
--- a/Application/Application.csproj
+++ b/Application/Application.csproj
@@ -25,11 +25,11 @@
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
diff --git a/Application/ApplicationManager.cs b/Application/ApplicationManager.cs
index bb0c6a07d..cfc816ecf 100644
--- a/Application/ApplicationManager.cs
+++ b/Application/ApplicationManager.cs
@@ -59,11 +59,12 @@ namespace IW4MAdmin.Application
private readonly ITranslationLookup _translationLookup;
private readonly IConfigurationHandler _commandConfiguration;
private readonly IGameServerInstanceFactory _serverInstanceFactory;
+ private readonly IParserRegexFactory _parserRegexFactory;
public ApplicationManager(ILogger logger, IMiddlewareActionHandler actionHandler, IEnumerable commands,
ITranslationLookup translationLookup, IConfigurationHandler commandConfiguration,
IConfigurationHandler appConfigHandler, IGameServerInstanceFactory serverInstanceFactory,
- IEnumerable plugins)
+ IEnumerable plugins, IParserRegexFactory parserRegexFactory)
{
MiddlewareActionHandler = actionHandler;
_servers = new ConcurrentBag();
@@ -74,8 +75,8 @@ namespace IW4MAdmin.Application
ConfigHandler = appConfigHandler;
StartTime = DateTime.UtcNow;
PageList = new PageList();
- AdditionalEventParsers = new List() { new BaseEventParser() };
- AdditionalRConParsers = new List() { new BaseRConParser() };
+ AdditionalEventParsers = new List() { new BaseEventParser(parserRegexFactory) };
+ AdditionalRConParsers = new List() { new BaseRConParser(parserRegexFactory) };
TokenAuthenticator = new TokenAuthentication();
_metaService = new MetaService();
_tokenSource = new CancellationTokenSource();
@@ -84,6 +85,7 @@ namespace IW4MAdmin.Application
_translationLookup = translationLookup;
_commandConfiguration = commandConfiguration;
_serverInstanceFactory = serverInstanceFactory;
+ _parserRegexFactory = parserRegexFactory;
Plugins = plugins;
}
@@ -771,7 +773,7 @@ namespace IW4MAdmin.Application
public IRConParser GenerateDynamicRConParser(string name)
{
- return new DynamicRConParser()
+ return new DynamicRConParser(_parserRegexFactory)
{
Name = name
};
@@ -779,7 +781,7 @@ namespace IW4MAdmin.Application
public IEventParser GenerateDynamicEventParser(string name)
{
- return new DynamicEventParser()
+ return new DynamicEventParser(_parserRegexFactory)
{
Name = name
};
diff --git a/Application/EventParsers/BaseEventParser.cs b/Application/EventParsers/BaseEventParser.cs
index c58d71c6c..ff89e95d6 100644
--- a/Application/EventParsers/BaseEventParser.cs
+++ b/Application/EventParsers/BaseEventParser.cs
@@ -2,18 +2,16 @@
using SharedLibraryCore.Database.Models;
using SharedLibraryCore.Interfaces;
using System;
-using System.Collections.Generic;
using System.Linq;
-using System.Text.RegularExpressions;
using static SharedLibraryCore.Server;
namespace IW4MAdmin.Application.EventParsers
{
public class BaseEventParser : IEventParser
{
- public BaseEventParser()
+ public BaseEventParser(IParserRegexFactory parserRegexFactory)
{
- Configuration = new DynamicEventParserConfiguration()
+ Configuration = new DynamicEventParserConfiguration(parserRegexFactory)
{
GameDirectory = "main",
};
@@ -66,6 +64,8 @@ namespace IW4MAdmin.Application.EventParsers
Configuration.Kill.AddMapping(ParserRegex.GroupType.Damage, 11);
Configuration.Kill.AddMapping(ParserRegex.GroupType.MeansOfDeath, 12);
Configuration.Kill.AddMapping(ParserRegex.GroupType.HitLocation, 13);
+
+ Configuration.Time.Pattern = @"^ *(([0-9]+):([0-9]+) |^[0-9]+ )";
}
public IEventParserConfiguration Configuration { get; set; }
@@ -80,44 +80,48 @@ namespace IW4MAdmin.Application.EventParsers
public virtual GameEvent GenerateGameEvent(string logLine)
{
- var timeMatch = Regex.Match(logLine, @"^ *(([0-9]+):([0-9]+) |^[0-9]+ )");
+ var timeMatch = Configuration.Time.PatternMatcher.Match(logLine);
int gameTime = 0;
-
+
if (timeMatch.Success)
{
- gameTime = (timeMatch.Groups.Values as IEnumerable