Removed some C#7 stuff

This commit is contained in:
RogueException
2016-06-09 12:39:38 -03:00
parent dea73042aa
commit 59e6b33cbb
2 changed files with 3 additions and 21 deletions

View File

@@ -7,37 +7,22 @@ namespace Discord
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public struct ChannelPermissions
{
#if CSHARP7
private static ChannelPermissions _allDM { get; } = new ChannelPermissions(0b000100_000000_0011111111_0000011001);
private static ChannelPermissions _allText { get; } = new ChannelPermissions(0b000000_000000_0001110011_0000000000);
private static ChannelPermissions _allVoice { get; } = new ChannelPermissions(0b000100_111111_0000000000_0000011001);
#else
//TODO: C#7 Candidate for binary literals
private static ChannelPermissions _allDM { get; } = new ChannelPermissions(Convert.ToUInt64("00010000000000111111110000011001", 2));
private static ChannelPermissions _allText { get; } = new ChannelPermissions(Convert.ToUInt64("00000000000000011100110000000000", 2));
private static ChannelPermissions _allVoice { get; } = new ChannelPermissions(Convert.ToUInt64("00010011111100000000000000011001", 2));
#endif
/// <summary> Gets a blank ChannelPermissions that grants no permissions. </summary>
public static ChannelPermissions None { get; } = new ChannelPermissions();
/// <summary> Gets a ChannelPermissions that grants all permissions for a given channelType. </summary>
public static ChannelPermissions All(IChannel channel)
{
#if CSHARP7
switch (channel)
{
case ITextChannel _: return _allText;
case IVoiceChannel _: return _allVoice;
case IDMChannel _: return _allDM;
default:
throw new ArgumentException("Unknown channel type", nameof(channel));
}
#else
//TODO: C#7 Candidate for typeswitch
if (channel is ITextChannel) return _allText;
if (channel is IVoiceChannel) return _allVoice;
if (channel is IDMChannel) return _allDM;
throw new ArgumentException("Unknown channel type", nameof(channel));
#endif
}
/// <summary> Gets a packed value representing all the permissions in this ChannelPermissions. </summary>

View File

@@ -10,11 +10,8 @@ namespace Discord
/// <summary> Gets a blank GuildPermissions that grants no permissions. </summary>
public static readonly GuildPermissions None = new GuildPermissions();
/// <summary> Gets a GuildPermissions that grants all permissions. </summary>
#if CSHARP7
public static readonly GuildPermissions All = new GuildPermissions(0b000111_111111_0011111111_0000111111);
#else
//TODO: C#7 Candidate for binary literals
public static readonly GuildPermissions All = new GuildPermissions(Convert.ToUInt64("00011111111100111111110000111111", 2));
#endif
/// <summary> Gets a packed value representing all the permissions in this GuildPermissions. </summary>
public ulong RawValue { get; }