Add a new .editorconfig and reformat code (#76)
*I'll start working on features and bugfixes after this PR, I promise* very short summary: - no more braceless statements - braces are on new lines now - `sealed` on everything that can be `sealed` - no more awkwardly looking alignment of fields/parameters - no more `Service` suffix on service fields. yeah. - no more `else`s. who needs them? - code style is now enforced by CI --------- Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
parent
4cb39a34b5
commit
84e730838b
39 changed files with 2917 additions and 623 deletions
|
@ -6,8 +6,10 @@ using Remora.Results;
|
|||
namespace Boyfriend.Data.Options;
|
||||
|
||||
/// <inheritdoc />
|
||||
public class LanguageOption : Option<CultureInfo> {
|
||||
private static readonly Dictionary<string, CultureInfo> CultureInfoCache = new() {
|
||||
public sealed class LanguageOption : Option<CultureInfo>
|
||||
{
|
||||
private static readonly Dictionary<string, CultureInfo> CultureInfoCache = new()
|
||||
{
|
||||
{ "en", new CultureInfo("en-US") },
|
||||
{ "ru", new CultureInfo("ru-RU") },
|
||||
{ "mctaylors-ru", new CultureInfo("tt-RU") }
|
||||
|
@ -15,18 +17,21 @@ public class LanguageOption : Option<CultureInfo> {
|
|||
|
||||
public LanguageOption(string name, string defaultValue) : base(name, CultureInfoCache[defaultValue]) { }
|
||||
|
||||
public override string Display(JsonNode settings) {
|
||||
public override string Display(JsonNode settings)
|
||||
{
|
||||
return Markdown.InlineCode(settings[Name]?.GetValue<string>() ?? "en");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override CultureInfo Get(JsonNode settings) {
|
||||
public override CultureInfo Get(JsonNode settings)
|
||||
{
|
||||
var property = settings[Name];
|
||||
return property != null ? CultureInfoCache[property.GetValue<string>()] : DefaultValue;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override Result Set(JsonNode settings, string from) {
|
||||
public override Result Set(JsonNode settings, string from)
|
||||
{
|
||||
return CultureInfoCache.ContainsKey(from.ToLowerInvariant())
|
||||
? base.Set(settings, from.ToLowerInvariant())
|
||||
: new ArgumentInvalidError(nameof(from), Messages.LanguageNotSupported);
|
||||
|
|
Reference in a new issue