AnkiIO 1.0.2
Build, validate, import, and export Anki-compatible decks from .NET
Loading...
Searching...
No Matches
ConventionalNoteTypeCache.cs
1namespace AnkiIO;
2
3internal sealed class ConventionalNoteTypeCache
4{
5 public AnkiNoteType? Basic { get; set; }
6
7 public AnkiNoteType? BasicAndReversed { get; set; }
8
9 public AnkiNoteType? Cloze { get; set; }
10
11 public void Observe(AnkiNoteType noteType)
12 {
13 if (Basic is null && AnkiNoteTypes.IsBasic(noteType))
14 {
15 Basic = noteType;
16 }
17 else if (BasicAndReversed is null && AnkiNoteTypes.IsBasicAndReversed(noteType))
18 {
19 BasicAndReversed = noteType;
20 }
21 else if (Cloze is null && AnkiNoteTypes.IsCloze(noteType))
22 {
23 Cloze = noteType;
24 }
25 }
26
27 public void CopyMissingTo(ConventionalNoteTypeCache destination)
28 {
29 if (Basic is not null)
30 {
31 destination.Observe(Basic);
32 }
33
34 if (BasicAndReversed is not null)
35 {
36 destination.Observe(BasicAndReversed);
37 }
38
39 if (Cloze is not null)
40 {
41 destination.Observe(Cloze);
42 }
43 }
44}