mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-08 06:47:56 +00:00
refactor: move JsonModelExt to PluralKit.Core (in individual model/patch files)
This commit is contained in:
parent
26c18d2f48
commit
11bd66e8d8
9 changed files with 193 additions and 186 deletions
|
|
@ -38,5 +38,17 @@ namespace PluralKit.Core
|
|||
output = input;
|
||||
return true;
|
||||
}
|
||||
|
||||
public static string ToJsonString(this PrivacyLevel level) => level.LevelName();
|
||||
|
||||
public static PrivacyLevel ParsePrivacy(this string input, string errorName)
|
||||
{
|
||||
if (input == null) return PrivacyLevel.Public;
|
||||
if (input == "") return PrivacyLevel.Private;
|
||||
if (input == "private") return PrivacyLevel.Private;
|
||||
if (input == "public") return PrivacyLevel.Public;
|
||||
throw new JsonModelParseError($"Could not parse {errorName} privacy.");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue