-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow creating parts of speech as CRDTs and setup a PoC of pre seedin…
…g them.
- Loading branch information
Showing
5 changed files
with
88 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Crdt; | ||
using Crdt.Changes; | ||
using Crdt.Entities; | ||
using MiniLcm; | ||
using PartOfSpeech = LcmCrdt.Objects.PartOfSpeech; | ||
|
||
namespace LcmCrdt.Changes; | ||
|
||
public class CreatePartOfSpeechChange(Guid entityId, MultiString name, bool predefined = false) | ||
: CreateChange<PartOfSpeech>(entityId), ISelfNamedType<CreatePartOfSpeechChange> | ||
{ | ||
public MultiString Name { get; } = name; | ||
public bool Predefined { get; } = predefined; | ||
|
||
public override async ValueTask<IObjectBase> NewEntity(Commit commit, ChangeContext context) | ||
{ | ||
return new PartOfSpeech { Id = EntityId, Name = Name, Predefined = Predefined }; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using Crdt; | ||
using Crdt.Entities; | ||
using LcmCrdt.Changes; | ||
using MiniLcm; | ||
|
||
namespace LcmCrdt.Objects; | ||
|
||
public class PartOfSpeech : MiniLcm.PartOfSpeech, IObjectBase<PartOfSpeech> | ||
{ | ||
Guid IObjectBase.Id | ||
{ | ||
get => Id; | ||
init => Id = value; | ||
} | ||
public DateTimeOffset? DeletedAt { get; set; } | ||
public bool Predefined { get; set; } | ||
public Guid[] GetReferences() | ||
{ | ||
return []; | ||
} | ||
|
||
public void RemoveReference(Guid id, Commit commit) | ||
{ | ||
} | ||
|
||
public IObjectBase Copy() | ||
{ | ||
return new PartOfSpeech | ||
{ | ||
Id = Id, | ||
Name = Name, | ||
DeletedAt = DeletedAt, | ||
Predefined = Predefined | ||
}; | ||
} | ||
|
||
public static async Task PredefinedPartsOfSpeech(DataModel dataModel, Guid clientId) | ||
{ | ||
//todo load from xml instead of hardcoding | ||
await dataModel.AddChanges(clientId, | ||
[ | ||
new CreatePartOfSpeechChange(new Guid("46e4fe08-ffa0-4c8b-bf98-2c56f38904d9"), new MultiString() { { "en", "Adverb" } }, true) | ||
], | ||
new Guid("023faebb-711b-4d2f-b34f-a15621fc66bb")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters