Added missing files
This commit is contained in:
16
src/Discord.Net/Events/BanEventArgs.cs
Normal file
16
src/Discord.Net/Events/BanEventArgs.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
37
src/Discord.Net/Extensions.cs
Normal file
37
src/Discord.Net/Extensions.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user