-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathWord.cs
More file actions
58 lines (50 loc) · 1.63 KB
/
Word.cs
File metadata and controls
58 lines (50 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using SIL.Harmony.Entities;
namespace SIL.Harmony.Sample.Models;
public class Word : IObjectBase<Word>
{
public required string Text { get; set; }
public string? Note { get; set; }
public Guid Id { get; init; }
public DateTimeOffset? DeletedAt { get; set; }
public Word? Antonym { get; set; }
public Guid? AntonymId { get; set; }
public Guid? ImageResourceId { get; set; }
public List<Tag> Tags { get; set; } = new();
public Guid[] GetReferences()
{
return Refs().ToArray();
IEnumerable<Guid> Refs()
{
if (AntonymId.HasValue) yield return AntonymId.Value;
if (ImageResourceId.HasValue) yield return ImageResourceId.Value;
}
}
public void RemoveReference(Guid id, CommitBase commit)
{
if (AntonymId == id)
{
AntonymId = null;
Antonym = null;
}
}
public IObjectBase Copy()
{
return new Word
{
Id = Id,
Text = Text,
Note = Note,
Antonym = Antonym,
AntonymId = AntonymId,
DeletedAt = DeletedAt,
ImageResourceId = ImageResourceId,
Tags = Tags.Select(t => t.Copy()).Cast<Tag>().ToList(),
};
}
public override string ToString()
{
return
$"{nameof(Text)}: {Text}, {nameof(Id)}: {Id}, {nameof(Note)}: {Note}, {nameof(DeletedAt)}: {DeletedAt}, {nameof(Antonym)}: {Antonym}, {nameof(AntonymId)}: {AntonymId}, {nameof(ImageResourceId)}: {ImageResourceId}" +
$", {nameof(Tags)}: {string.Join(", ", Tags.Select(t => t.Text))}";
}
}