Helpers
TokenHelper.cs
//-----------------------------------------------------------------------
//
// Copyright © Wohs Inc.
//
//-----------------------------------------------------------------------
namespace Lurker.Helpers
{
using System.Text.RegularExpressions;
using Lurker.Models;
using Lurker.Patreon.Events;
///
/// Represents token helper.
///
public static clast TokenHelper
{
#region Fields
///
/// The item name.
///
public static readonly string ItemName = "{ItemName}";
///
/// The buyer name.
///
public static readonly string BuyerName = "{BuyerName}";
///
/// The price.
///
public static readonly string Price = "{Price}";
///
/// The location.
///
public static readonly string Location = "{Location}";
#endregion
#region Methods
///
/// Replaces the token.
///
/// The message.
/// The trade.
///
/// The string with token replaced.
///
public static string ReplaceToken(string message, TradeEvent trade)
{
message = Regex.Replace(message, ItemName, trade.ItemName, RegexOptions.IgnoreCase);
message = Regex.Replace(message, BuyerName, trade.PlayerName, RegexOptions.IgnoreCase);
message = Regex.Replace(message, Location, PoeApplicationContext.Location, RegexOptions.IgnoreCase);
if (trade.Price.CurrencyType != Patreon.Models.CurrencyType.Unknown)
{
message = Regex.Replace(message, Price, trade.Price.ToString(), RegexOptions.IgnoreCase);
}
return message;
}
#endregion
}
}