C#7 TODOs

This commit is contained in:
Christopher F
2017-04-23 15:13:31 -04:00
parent 3dfa54e56e
commit 6000b15c4d
5 changed files with 59 additions and 62 deletions

View File

@@ -20,13 +20,14 @@ namespace Discord
/// <summary> Gets a ChannelPermissions that grants all permissions for a given channelType. </summary>
public static ChannelPermissions All(IChannel channel)
{
//TODO: C#7 Candidate for typeswitch
if (channel is ITextChannel) return Text;
if (channel is IVoiceChannel) return Voice;
if (channel is IDMChannel) return DM;
if (channel is IGroupChannel) return Group;
throw new ArgumentException("Unknown channel type", nameof(channel));
switch (channel)
{
case ITextChannel _: return Text;
case IVoiceChannel _: return Voice;
case IDMChannel _: return DM;
case IGroupChannel _: return Group;
default: throw new ArgumentException("Unknown channel type", nameof(channel));
}
}
/// <summary> Gets a packed value representing all the permissions in this ChannelPermissions. </summary>

View File

@@ -150,9 +150,7 @@ namespace Discord
if (perms != null)
resolvedPermissions = (resolvedPermissions & ~perms.Value.DenyValue) | perms.Value.AllowValue;
//TODO: C#7 Typeswitch candidate
var textChannel = channel as ITextChannel;
if (textChannel != null)
if (channel is ITextChannel textChannel)
{
if (!GetValue(resolvedPermissions, ChannelPermission.ReadMessages))
{