Browse Source

Added missing files

tags/docs-0.9
RogueException 9 years ago
parent
commit
5e1c568489
2 changed files with 53 additions and 0 deletions
  1. +16
    -0
      src/Discord.Net/Events/BanEventArgs.cs
  2. +37
    -0
      src/Discord.Net/Extensions.cs

+ 16
- 0
src/Discord.Net/Events/BanEventArgs.cs 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;
}
}
}

+ 37
- 0
src/Discord.Net/Extensions.cs 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;
}
}
}
}

Loading…
Cancel
Save