Architecture refactor (#63)

This commit is contained in:
Alexey Golub
2018-06-25 01:59:15 +03:00
committed by GitHub
parent d958f613a3
commit 481991bd00
52 changed files with 1484 additions and 1846 deletions

View File

@@ -1,22 +1,23 @@
using System.IO;
using System.Reflection;
using System.Resources;
using System;
using System.Drawing;
using Tyrrrz.Extensions;
namespace DiscordChatExporter.Core.Internal
{
internal static class Extensions
{
public static string GetManifestResourceString(this Assembly assembly, string resourceName)
public static string ToSnowflake(this DateTime dateTime)
{
var stream = assembly.GetManifestResourceStream(resourceName);
if (stream == null)
throw new MissingManifestResourceException($"Could not find resource [{resourceName}].");
using (stream)
using (var reader = new StreamReader(stream))
{
return reader.ReadToEnd();
}
const long epoch = 62135596800000;
var unixTime = dateTime.ToUniversalTime().Ticks / TimeSpan.TicksPerMillisecond - epoch;
var value = ((ulong) unixTime - 1420070400000UL) << 22;
return value.ToString();
}
public static string Base64Encode(this string str) => str.GetBytes().ToBase64();
public static string Base64Decode(this string str) => str.FromBase64().GetString();
public static Color ResetAlpha(this Color color) => Color.FromArgb(1, color);
}
}