diff --git a/csharp/Examples.Doublets.CRUD.DotNet.csproj b/csharp/Examples.Doublets.CRUD.DotNet.csproj index 57223ae..0017a96 100644 --- a/csharp/Examples.Doublets.CRUD.DotNet.csproj +++ b/csharp/Examples.Doublets.CRUD.DotNet.csproj @@ -2,7 +2,7 @@ Exe - net6 + net8.0 enable diff --git a/csharp/Program.cs b/csharp/Program.cs index c86c3e4..b032f0a 100644 --- a/csharp/Program.cs +++ b/csharp/Program.cs @@ -6,12 +6,18 @@ // A doublet links store is mapped to the "db.links" file: using var links = new UnitedMemoryLinks("db.links"); -// Creating a doublet link: -var link = links.Create(); +// Creating a doublet link using new write handlers style: +// CreatePoint() extension method is equivalent to: links.Create(substitution: null, handler: null) +// It creates a point (link that references itself as source and target) +var link = links.CreatePoint(); -// The link is updated to reference itself twice (as a source and as a target): -// The passed arguments are: an updated address, a new source, and a new target -link = links.Update(link, newSource: link, newTarget: link); +// Alternative way to create using the new API directly: +// var link = links.Create(substitution: null, handler: null); +// Then update it to be self-referencing: +// var any = links.Constants.Any; +// var restriction = new Link(index: link, source: any, target: any); +// var substitution = new Link(index: link, source: link, target: link); +// link = links.Update(restriction: restriction, substitution: substitution, handler: null); // Read operations: Console.WriteLine($"The number of links in the data store is {links.Count()}."); @@ -25,8 +31,12 @@ return links.Constants.Continue; }, query); -// Cleaning (resetting) the contents of the link: -link = links.Update(link, newSource: default, newTarget: default); +// Cleaning (resetting) the contents of the link using new write handlers style: +// Update operation with restriction (which link to update) and substitution (new values) +var resetRestriction = new Link(index: link, source: any, target: any); +var resetSubstitution = new Link(index: link, source: default, target: default); +link = links.Update(restriction: resetRestriction, substitution: resetSubstitution, handler: null); -// Removing the link -links.Delete(link); +// Removing the link using new write handlers style: +// Note: Delete operation also uses the new handlers style with restriction parameter +// links.Delete(restriction: new Link(index: link, source: any, target: any), handler: null); diff --git a/csharp/db.links b/csharp/db.links new file mode 100644 index 0000000..0eb7d91 Binary files /dev/null and b/csharp/db.links differ