Skip to content

Commit

Permalink
Minor
Browse files Browse the repository at this point in the history
  • Loading branch information
rampaa committed Dec 22, 2024
1 parent b08ac49 commit 84acd9a
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 24 deletions.
7 changes: 3 additions & 4 deletions JL.Core/Dicts/Dict.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace JL.Core.Dicts;

public sealed class Dict(DictType type, string name, string path, bool active, int priority, int size, bool ready, DictOptions options)
public sealed class Dict(DictType type, string name, string path, bool active, int priority, int size, DictOptions options)
{
public DictType Type { get; internal set; } = type;
public string Name { get; set; } = name;
Expand All @@ -14,12 +14,11 @@ public sealed class Dict(DictType type, string name, string path, bool active, i

// ReSharper disable once MemberCanBeInternal
public int Size { get; set; } = size;

[JsonIgnore] public bool Ready { get; set; } = ready;
public DictOptions Options { get; set; } = options;
[JsonIgnore] public bool Ready { get; set; } // = false;

#pragma warning disable CA2227
[JsonIgnore] public IDictionary<string, IList<IDictRecord>> Contents { get; set; } = FrozenDictionary<string, IList<IDictRecord>>.Empty;
#pragma warning restore CA2227

public DictOptions Options { get; set; } = options;
}
14 changes: 7 additions & 7 deletions JL.Core/Dicts/DictUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static class DictUtils
nameof(DictType.ProfileCustomWordDictionary), new Dict(DictType.ProfileCustomWordDictionary,
"Custom Word Dictionary (Profile)",
Path.Join(ProfileUtils.ProfileFolderPath, "Default_Custom_Words.txt"),
true, -1, 128, false,
true, -1, 128,
new DictOptions(
new UseDBOption(false),
new NoAllOption(false),
Expand All @@ -56,7 +56,7 @@ public static class DictUtils
nameof(DictType.ProfileCustomNameDictionary), new Dict(DictType.ProfileCustomNameDictionary,
"Custom Name Dictionary (Profile)",
Path.Join(ProfileUtils.ProfileFolderPath, "Default_Custom_Names.txt"),
true, 0, 128, false,
true, 0, 128,
new DictOptions(
new UseDBOption(false),
new NoAllOption(false)))
Expand All @@ -65,7 +65,7 @@ public static class DictUtils
nameof(DictType.CustomWordDictionary), new Dict(DictType.CustomWordDictionary,
"Custom Word Dictionary",
Path.Join(Utils.ResourcesPath, "custom_words.txt"),
true, 1, 128, false,
true, 1, 128,
new DictOptions(
new UseDBOption(false),
new NoAllOption(false),
Expand All @@ -75,15 +75,15 @@ public static class DictUtils
nameof(DictType.CustomNameDictionary), new Dict(DictType.CustomNameDictionary,
"Custom Name Dictionary",
Path.Join(Utils.ResourcesPath, "custom_names.txt"),
true, 2, 128, false,
true, 2, 128,
new DictOptions(
new UseDBOption(false),
new NoAllOption(false)))
},
{
nameof(DictType.JMdict), new Dict(DictType.JMdict, nameof(DictType.JMdict),
Path.Join(Utils.ResourcesPath, $"{nameof(DictType.JMdict)}.xml"),
true, 3, 500000, false,
true, 3, 500000,
new DictOptions(
new UseDBOption(true),
new NoAllOption(false),
Expand All @@ -108,7 +108,7 @@ public static class DictUtils
{
nameof(DictType.Kanjidic), new Dict(DictType.Kanjidic, nameof(DictType.Kanjidic),
Path.Join(Utils.ResourcesPath, "kanjidic2.xml"),
true, 4, 13108, false,
true, 4, 13108,
new DictOptions(
new UseDBOption(true),
new NoAllOption(false),
Expand All @@ -117,7 +117,7 @@ public static class DictUtils
{
nameof(DictType.JMnedict), new Dict(DictType.JMnedict, nameof(DictType.JMnedict),
Path.Join(Utils.ResourcesPath, $"{nameof(DictType.JMnedict)}.xml"),
true, 5, 700000, false,
true, 5, 700000,
new DictOptions(
new UseDBOption(true),
new NoAllOption(false),
Expand Down
4 changes: 2 additions & 2 deletions JL.Core/Freqs/Freq.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace JL.Core.Freqs;

public sealed class Freq(FreqType type, string name, string path, bool active, int priority, int size, int maxValue, bool ready, FreqOptions options)
public sealed class Freq(FreqType type, string name, string path, bool active, int priority, int size, int maxValue, FreqOptions options)
{
public FreqType Type { get; } = type;
public string Name { get; set; } = name;
Expand All @@ -18,7 +18,7 @@ public sealed class Freq(FreqType type, string name, string path, bool active, i
// ReSharper disable once MemberCanBeInternal
public int MaxValue { get; set; } = maxValue;

[JsonIgnore] public bool Ready { get; set; } = ready;
[JsonIgnore] public bool Ready { get; set; } // = false;

#pragma warning disable CA2227
[JsonIgnore] public IDictionary<string, IList<FrequencyRecord>> Contents { get; set; } = FrozenDictionary<string, IList<FrequencyRecord>>.Empty;
Expand Down
6 changes: 3 additions & 3 deletions JL.Core/Freqs/FreqUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ public static class FreqUtils
"VN (Nazeka)",
new Freq(FreqType.Nazeka, "VN (Nazeka)",
Path.Join(Utils.ResourcesPath, "freqlist_vns.json"),
true, 1, 57273, 35894, false, new FreqOptions(new UseDBOption(true), new HigherValueMeansHigherFrequencyOption(false)))
true, 1, 57273, 35894, new FreqOptions(new UseDBOption(true), new HigherValueMeansHigherFrequencyOption(false)))
},
{
"Narou (Nazeka)",
new Freq(FreqType.Nazeka, "Narou (Nazeka)",
Path.Join(Utils.ResourcesPath, "freqlist_narou.json"),
false, 2, 75588, 48528, false, new FreqOptions(new UseDBOption(true), new HigherValueMeansHigherFrequencyOption(false)))
false, 2, 75588, 48528, new FreqOptions(new UseDBOption(true), new HigherValueMeansHigherFrequencyOption(false)))
},
{
"Novel (Nazeka)",
new Freq(FreqType.Nazeka, "Novel (Nazeka)",
Path.Join(Utils.ResourcesPath, "freqlist_novels.json"),
false, 3, 114348, 74633, false, new FreqOptions(new UseDBOption(true), new HigherValueMeansHigherFrequencyOption(false)))
false, 3, 114348, 74633, new FreqOptions(new UseDBOption(true), new HigherValueMeansHigherFrequencyOption(false)))
}
};

Expand Down
24 changes: 18 additions & 6 deletions JL.Core/Utilities/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,17 @@ public static partial class Utils

internal static readonly JsonSerializerOptions s_jsoNotIgnoringNull = new()
{
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
RespectNullableAnnotations = true,
RespectRequiredConstructorParameters = true
};

internal static readonly JsonSerializerOptions s_jsoIgnoringNull = new()
{
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
RespectNullableAnnotations = true,
RespectRequiredConstructorParameters = true
};

internal static readonly JsonSerializerOptions s_jsoNotIgnoringNullWithEnumConverter = new()
Expand All @@ -66,7 +70,9 @@ public static partial class Utils
{
new JsonStringEnumConverter()
},
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
RespectNullableAnnotations = true,
RespectRequiredConstructorParameters = true
};

internal static readonly JsonSerializerOptions s_jsoIgnoringNullWithEnumConverter = new()
Expand All @@ -76,7 +82,9 @@ public static partial class Utils
new JsonStringEnumConverter()
},
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
RespectNullableAnnotations = true,
RespectRequiredConstructorParameters = true
};

internal static readonly JsonSerializerOptions s_jsoNotIgnoringNullWithEnumConverterAndIndentation = new()
Expand All @@ -86,7 +94,9 @@ public static partial class Utils
new JsonStringEnumConverter()
},
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
WriteIndented = true
WriteIndented = true,
RespectNullableAnnotations = true,
RespectRequiredConstructorParameters = true
};

internal static readonly JsonSerializerOptions s_jsoIgnoringNullWithEnumConverterAndIndentation = new()
Expand All @@ -97,7 +107,9 @@ public static partial class Utils
},
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
WriteIndented = true
WriteIndented = true,
RespectNullableAnnotations = true,
RespectRequiredConstructorParameters = true
};

internal static readonly FrozenDictionary<string, string> s_iso6392BTo2T = new Dictionary<string, string>(20, StringComparer.Ordinal)
Expand Down
2 changes: 1 addition & 1 deletion JL.Windows/GUI/AddDictionaryWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private void SaveButton_Click(object sender, RoutedEventArgs e)
}

DictOptions options = _dictOptionsControl.GetDictOptions(type);
Dict dict = new(type, name, path, true, DictUtils.Dicts.Count + 1, 0, false, options);
Dict dict = new(type, name, path, true, DictUtils.Dicts.Count + 1, 0, options);
DictUtils.Dicts.Add(name, dict);

if (dict.Type is DictType.PitchAccentYomichan)
Expand Down
2 changes: 1 addition & 1 deletion JL.Windows/GUI/AddFrequencyWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private void SaveButton_Click(object sender, RoutedEventArgs e)
FreqOptions options = _freqOptionsControl.GetFreqOptions(type);

FreqUtils.FreqDicts.Add(name,
new Freq(type, name, path, true, FreqUtils.FreqDicts.Count + 1, 0, 0, false, options));
new Freq(type, name, path, true, FreqUtils.FreqDicts.Count + 1, 0, 0, options));

Close();
}
Expand Down

0 comments on commit 84acd9a

Please sign in to comment.