diff options
author | Ben Harris <ben@tilde.team> | 2020-05-14 23:06:10 -0400 |
---|---|---|
committer | Ben Harris <ben@tilde.team> | 2020-05-14 23:17:47 -0400 |
commit | 21f1e95fb8e935134a969bc3d729964d8d2aadfa (patch) | |
tree | db2be27e9b5ac48e19f92b56cbad68ab59f7099e /IRCStates/ISupportPrefix.cs | |
parent | 304df7805b9925c2edd992fd4177eef80197f807 (diff) |
rename Irc to IRC
Diffstat (limited to 'IRCStates/ISupportPrefix.cs')
-rw-r--r-- | IRCStates/ISupportPrefix.cs | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/IRCStates/ISupportPrefix.cs b/IRCStates/ISupportPrefix.cs new file mode 100644 index 0000000..35c5344 --- /dev/null +++ b/IRCStates/ISupportPrefix.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; + +namespace IRCStates +{ + public class ISupportPrefix + { + public ISupportPrefix(string splitVal) + { + if (splitVal == null) throw new ArgumentNullException(nameof(splitVal)); + + var split = splitVal.Substring(1).Split(')', 2); + Modes = new List<string>(); + Modes.AddRange(split[0].Select(c => c.ToString(CultureInfo.InvariantCulture))); + Prefixes = new List<string>(); + Prefixes.AddRange(split[1].Select(c => c.ToString(CultureInfo.InvariantCulture))); + } + + public List<string> Modes { get; set; } + public List<string> Prefixes { get; set; } + + public string FromMode(char mode) + { + return FromMode(mode.ToString(CultureInfo.InvariantCulture)); + } + + public string FromMode(string mode) + { + return Modes.Contains(mode) ? Prefixes[Modes.IndexOf(mode)] : null; + } + + public string FromPrefix(char prefix) + { + return FromPrefix(prefix.ToString(CultureInfo.InvariantCulture)); + } + + public string FromPrefix(string prefix) + { + return Prefixes.Contains(prefix) ? Modes[Prefixes.IndexOf(prefix)] : null; + } + } +} |