|
|
|
@ -7,8 +7,6 @@ namespace STranslateDLL;
|
|
|
|
|
public static class Utilities
|
|
|
|
|
{
|
|
|
|
|
public const string Url = "https://www2.deepl.com/jsonrpc";
|
|
|
|
|
private static long _nextId;
|
|
|
|
|
private static bool _hasInit;
|
|
|
|
|
|
|
|
|
|
public static readonly Dictionary<bool, string> TextTypeDic = new()
|
|
|
|
|
{
|
|
|
|
@ -21,7 +19,7 @@ public static class Utilities
|
|
|
|
|
{
|
|
|
|
|
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
|
|
|
|
|
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingDefault,
|
|
|
|
|
WriteIndented = true
|
|
|
|
|
// WriteIndented = true
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public static string Serialize(object data)
|
|
|
|
@ -29,17 +27,6 @@ public static class Utilities
|
|
|
|
|
return JsonSerializer.Serialize(data, GetOptions);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void Initial()
|
|
|
|
|
{
|
|
|
|
|
if (_hasInit) return;
|
|
|
|
|
|
|
|
|
|
var rand = new Random();
|
|
|
|
|
var number = rand.NextInt64(99999) + 8300000;
|
|
|
|
|
_nextId = number * 1000;
|
|
|
|
|
|
|
|
|
|
_hasInit = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static bool IsRichText(string text)
|
|
|
|
|
{
|
|
|
|
|
return text.Contains('<') && text.Contains('>');
|
|
|
|
@ -54,7 +41,9 @@ public static class Utilities
|
|
|
|
|
|
|
|
|
|
public static long CreateId()
|
|
|
|
|
{
|
|
|
|
|
return Interlocked.Increment(ref _nextId);
|
|
|
|
|
var rand = new Random();
|
|
|
|
|
var number = rand.NextInt64(99999) + 8300000;
|
|
|
|
|
return number * 1000;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static string AdjustJsonContent(string json, long id)
|
|
|
|
|