HISP/HorseIsleServer/LibHISP/Security/BBCode.cs
2022-07-25 19:52:05 +12:00

35 lines
1 KiB
C#
Executable file

using System.Collections.Generic;
namespace HISP.Security
{
public class BBCode
{
public BBCode(string tag, string meta)
{
this.Tag = tag;
this.MetaTranslation = meta;
bbcodeTranslations.Add(this);
}
private static List<BBCode> bbcodeTranslations = new List<BBCode>();
public string Tag;
public string MetaTranslation;
public static string EncodeMetaToBBCode(string message)
{
foreach (BBCode code in bbcodeTranslations)
{
message = message.Replace(code.MetaTranslation, code.Tag);
}
return message;
}
public static string EncodeBBCodeToMeta(string message)
{
foreach(BBCode code in bbcodeTranslations)
{
message = message.Replace(code.Tag, code.MetaTranslation);
message = message.Replace(code.Tag.ToUpper(), code.MetaTranslation);
}
return message;
}
}
}