PluralKit/PluralKit.Core/Utils/InitUtils.cs

33 lines
958 B
C#
Raw Normal View History

2021-08-27 15:03:47 +00:00
using System.IO;
using Microsoft.Extensions.Configuration;
using Newtonsoft.Json;
using NodaTime;
using NodaTime.Serialization.JsonNet;
2021-08-27 15:03:47 +00:00
namespace PluralKit.Core
{
public static class InitUtils
{
2020-06-13 17:36:43 +00:00
public static void InitStatic()
{
Database.InitStatic();
}
2021-08-27 15:03:47 +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
public static JsonSerializerSettings BuildSerializerSettings() => new JsonSerializerSettings().BuildSerializerSettings();
public static JsonSerializerSettings BuildSerializerSettings(this JsonSerializerSettings settings)
{
settings.ConfigureForNodaTime(DateTimeZoneProviders.Tzdb);
return settings;
}
}
}