Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion csharp/Examples.Doublets.CRUD.DotNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>

Expand Down
28 changes: 19 additions & 9 deletions csharp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@
// A doublet links store is mapped to the "db.links" file:
using var links = new UnitedMemoryLinks<uint>("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<uint>(index: link, source: any, target: any);
// var substitution = new Link<uint>(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()}.");
Expand All @@ -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<uint>(index: link, source: any, target: any);
var resetSubstitution = new Link<uint>(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<uint>(index: link, source: any, target: any), handler: null);
Binary file added csharp/db.links
Binary file not shown.
Loading