feat: upgrade to .NET 6, refactor everything
This commit is contained in:
@@ -1,54 +1,50 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
using Serilog.Formatting.Elasticsearch;
|
||||
using Serilog.Formatting.Json;
|
||||
|
||||
namespace PluralKit.Core
|
||||
namespace PluralKit.Core;
|
||||
|
||||
public class ScalarFormatting
|
||||
{
|
||||
public class ScalarFormatting
|
||||
private static bool Write(object value, TextWriter output)
|
||||
{
|
||||
private static bool Write(object value, TextWriter output)
|
||||
if (value is SystemId si)
|
||||
output.Write(si.Value);
|
||||
else if (value is MemberId mi)
|
||||
output.Write(mi.Value);
|
||||
else if (value is GroupId gi)
|
||||
output.Write(gi.Value);
|
||||
else if (value is SwitchId swi)
|
||||
output.Write(swi.Value);
|
||||
else
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void WriteV(object value, TextWriter output) => Write(value, output);
|
||||
|
||||
public class Elasticsearch: ElasticsearchJsonFormatter
|
||||
{
|
||||
public Elasticsearch(bool omitEnclosingObject = false, string closingDelimiter = null,
|
||||
bool renderMessage = true, IFormatProvider formatProvider = null,
|
||||
ISerializer serializer = null, bool inlineFields = false,
|
||||
bool renderMessageTemplate = true, bool formatStackTraceAsArray = false) : base(
|
||||
omitEnclosingObject, closingDelimiter, renderMessage, formatProvider, serializer, inlineFields,
|
||||
renderMessageTemplate, formatStackTraceAsArray)
|
||||
{
|
||||
if (value is SystemId si)
|
||||
output.Write(si.Value);
|
||||
else if (value is MemberId mi)
|
||||
output.Write(mi.Value);
|
||||
else if (value is GroupId gi)
|
||||
output.Write(gi.Value);
|
||||
else if (value is SwitchId swi)
|
||||
output.Write(swi.Value);
|
||||
else
|
||||
return false;
|
||||
return true;
|
||||
AddLiteralWriter(typeof(SystemId), WriteV);
|
||||
AddLiteralWriter(typeof(MemberId), WriteV);
|
||||
AddLiteralWriter(typeof(GroupId), WriteV);
|
||||
AddLiteralWriter(typeof(SwitchId), WriteV);
|
||||
}
|
||||
}
|
||||
|
||||
private static void WriteV(object value, TextWriter output) => Write(value, output);
|
||||
|
||||
public class Elasticsearch: ElasticsearchJsonFormatter
|
||||
public class JsonValue: JsonValueFormatter
|
||||
{
|
||||
protected override void FormatLiteralValue(object value, TextWriter output)
|
||||
{
|
||||
public Elasticsearch(bool omitEnclosingObject = false, string closingDelimiter = null,
|
||||
bool renderMessage = true, IFormatProvider formatProvider = null,
|
||||
ISerializer serializer = null, bool inlineFields = false,
|
||||
bool renderMessageTemplate = true, bool formatStackTraceAsArray = false) : base(
|
||||
omitEnclosingObject, closingDelimiter, renderMessage, formatProvider, serializer, inlineFields,
|
||||
renderMessageTemplate, formatStackTraceAsArray)
|
||||
{
|
||||
AddLiteralWriter(typeof(SystemId), WriteV);
|
||||
AddLiteralWriter(typeof(MemberId), WriteV);
|
||||
AddLiteralWriter(typeof(GroupId), WriteV);
|
||||
AddLiteralWriter(typeof(SwitchId), WriteV);
|
||||
}
|
||||
}
|
||||
|
||||
public class JsonValue: JsonValueFormatter
|
||||
{
|
||||
protected override void FormatLiteralValue(object value, TextWriter output)
|
||||
{
|
||||
if (Write(value, output))
|
||||
return;
|
||||
base.FormatLiteralValue(value, output);
|
||||
}
|
||||
if (Write(value, output))
|
||||
return;
|
||||
base.FormatLiteralValue(value, output);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user