2017-05-31 01:31:56 -04:00
|
|
|
|
using System;
|
2019-02-18 20:30:38 -05:00
|
|
|
|
using System.Threading;
|
|
|
|
|
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
|
|
|
|
|
{
|
|
|
|
|
public string Name { get; private set; }
|
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
|
|
|
|
|
2019-02-19 20:39:09 -05:00
|
|
|
|
public async Task<string> ProcessAsync(Server server)
|
2017-05-31 01:31:56 -04:00
|
|
|
|
{
|
2019-02-19 20:39:09 -05:00
|
|
|
|
string result = await _asyncValue(server);
|
|
|
|
|
return result;
|
2017-05-31 01:31:56 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|