2017-05-31 01:31:56 -04:00
|
|
|
|
using System;
|
2019-02-18 20:30:38 -05:00
|
|
|
|
using System.Threading.Tasks;
|
2017-05-31 01:31:56 -04:00
|
|
|
|
|
2018-04-08 02:44:42 -04:00
|
|
|
|
namespace SharedLibraryCore.Helpers
|
2017-05-31 01:31:56 -04:00
|
|
|
|
{
|
|
|
|
|
public class MessageToken
|
|
|
|
|
{
|
2019-02-19 20:39:09 -05:00
|
|
|
|
private readonly Func<Server, Task<string>> _asyncValue;
|
2019-02-18 20:30:38 -05:00
|
|
|
|
|
|
|
|
|
|
2019-02-19 20:39:09 -05:00
|
|
|
|
public MessageToken(string Name, Func<Server, Task<string>> Value)
|
2017-05-31 01:31:56 -04:00
|
|
|
|
{
|
|
|
|
|
this.Name = Name;
|
2019-02-18 20:30:38 -05:00
|
|
|
|
_asyncValue = Value;
|
2017-05-31 01:31:56 -04:00
|
|
|
|
}
|
2019-02-18 20:30:38 -05:00
|
|
|
|
|
2022-01-26 11:32:16 -05:00
|
|
|
|
public string Name { get; }
|
|
|
|
|
|
2019-02-19 20:39:09 -05:00
|
|
|
|
public async Task<string> ProcessAsync(Server server)
|
2017-05-31 01:31:56 -04:00
|
|
|
|
{
|
2022-01-26 11:32:16 -05:00
|
|
|
|
var result = await _asyncValue(server);
|
2019-02-19 20:39:09 -05:00
|
|
|
|
return result;
|
2017-05-31 01:31:56 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
2022-01-26 11:32:16 -05:00
|
|
|
|
}
|