2020-02-12 14:16:19 +00:00
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
|
|
using NodaTime;
|
|
|
|
using NodaTime.Serialization.JsonNet;
|
|
|
|
|
2021-11-27 02:10:56 +00:00
|
|
|
namespace PluralKit.Core;
|
|
|
|
|
|
|
|
public static class InitUtils
|
2021-08-27 15:03:47 +00:00
|
|
|
{
|
2021-11-27 02:10:56 +00:00
|
|
|
public static void InitStatic()
|
2020-02-12 14:16:19 +00:00
|
|
|
{
|
2021-11-27 02:10:56 +00:00
|
|
|
Database.InitStatic();
|
|
|
|
}
|
2021-08-27 15:03:47 +00:00
|
|
|
|
2021-11-27 02:10:56 +00:00
|
|
|
public static IConfigurationBuilder BuildConfiguration(string[] args) => new ConfigurationBuilder()
|
|
|
|
.SetBasePath(Directory.GetCurrentDirectory())
|
|
|
|
.AddJsonFile("pluralkit.conf", true)
|
|
|
|
.AddEnvironmentVariables()
|
|
|
|
.AddCommandLine(args);
|
2021-08-27 15:03:47 +00:00
|
|
|
|
2021-11-27 02:10:56 +00:00
|
|
|
public static JsonSerializerSettings BuildSerializerSettings() =>
|
|
|
|
new JsonSerializerSettings().BuildSerializerSettings();
|
2020-02-12 14:16:19 +00:00
|
|
|
|
2021-11-27 02:10:56 +00:00
|
|
|
public static JsonSerializerSettings BuildSerializerSettings(this JsonSerializerSettings settings)
|
|
|
|
{
|
|
|
|
settings.ConfigureForNodaTime(DateTimeZoneProviders.Tzdb);
|
|
|
|
return settings;
|
2020-02-12 14:16:19 +00:00
|
|
|
}
|
|
|
|
}
|