1
0
mirror of https://github.com/RaidMax/IW4M-Admin.git synced 2025-06-10 15:20:48 -05:00

implement RSS feed in auto messages for issue #53

modified automessages to use async mesthods instead of synchronous
This commit is contained in:
RaidMax
2019-02-18 19:30:38 -06:00
parent ea40f17f7b
commit cd49a9843e
10 changed files with 1574 additions and 29 deletions

View File

@ -1,20 +1,24 @@
using System;
using System.Threading;
using System.Threading.Tasks;
namespace SharedLibraryCore.Helpers
{
public class MessageToken
{
public string Name { get; private set; }
Func<Server, string> Value;
public MessageToken(string Name, Func<Server, string> Value)
private readonly Func<Server, Task<object>> _asyncValue;
public MessageToken(string Name, Func<Server, Task<object>> Value)
{
this.Name = Name;
this.Value = Value;
_asyncValue = Value;
}
public string Process(Server server)
public Task<object> ProcessAsync(Server server)
{
return this.Value(server);
return _asyncValue(server);
}
}
}

View File

@ -183,7 +183,7 @@ namespace SharedLibraryCore
return CurrentLocalization.LocalizationIndex[$"GLOBAL_PERMISSION_{perm.ToString().ToUpper()}"];
}
public static String ProcessMessageToken(this Server server, IList<Helpers.MessageToken> tokens, String str)
public async static Task<string> ProcessMessageToken(this Server server, IList<Helpers.MessageToken> tokens, String str)
{
MatchCollection RegexMatches = Regex.Matches(str, @"\{\{[A-Z]+\}\}", RegexOptions.IgnoreCase);
foreach (Match M in RegexMatches)
@ -195,7 +195,7 @@ namespace SharedLibraryCore
if (found != null)
{
str = str.Replace(Match, found.Process(server));
str = str.Replace(Match, (await found.ProcessAsync(server)).ToString());
}
}