Added missing files

This commit is contained in:
RogueException
2015-12-22 20:31:51 -04:00
parent 0d1e69600c
commit 5e1c568489
2 changed files with 53 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
using System;
namespace Discord
{
public class BanEventArgs : EventArgs
{
public Server Server { get; }
public ulong UserId { get; }
public BanEventArgs(Server server, ulong userId)
{
Server = server;
UserId = userId;
}
}
}

View File

@@ -0,0 +1,37 @@
using System;
using System.Collections.Concurrent;
using System.Globalization;
using System.Runtime.CompilerServices;
namespace Discord
{
internal static class InternalExtensions
{
internal static readonly IFormatProvider _format = CultureInfo.InvariantCulture;
public static ulong ToId(this string value)
=> ulong.Parse(value, NumberStyles.None, _format);
public static ulong? ToNullableId(this string value)
=> value == null ? (ulong?)null : ulong.Parse(value, NumberStyles.None, _format);
public static string ToIdString(this ulong value)
=> value.ToString(_format);
public static string ToIdString(this ulong? value)
=> value?.ToString(_format);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool HasBit(this uint value, byte bit) => ((value >> bit) & 1U) == 1;
public static bool TryGetAdd<TKey, TValue>(this ConcurrentDictionary<TKey, TValue> d,
TKey key, Func<TKey, TValue> factory, out TValue result)
{
while (true)
{
if (d.TryGetValue(key, out result))
return false;
if (d.TryAdd(key, factory(key)))
return true;
}
}
}
}