I’m trying to implement ICustomRegion in C#, i want it that way so i can use it as a context provider to inject services in processes also written in C#. However there is something I can’t really understand:
using VL.Core;
using VL.Core.Import;
using VL.Core.PublicAPI;
using VL.Lib.Collections;
namespace VL.SharpRegion
{
[ProcessNode(
Name = "SharpRegion",
HasStateOutput = true,
FragmentSelection = FragmentSelection.Explicit
)]
public class SharpRegion : ICustomRegion
{
// Test something i want to provide
public record SharpRegionRecord(int Test);
private ICustomRegionPatch? _currentPatch;
private SharpRegionRecord _sharedRecord;
// ICustomRegion implementation
public Spread<BorderControlPointDescription> Inputs { get; private set; }
public Spread<BorderControlPointDescription> Outputs { get; private set; }
public Spread<IncomingLinkDescription> IncomingLinks { get; private set; }
public Spread<object> InputValues { get; private set; }
public IReadOnlyList<object> OutputValues { private get; set; }
public Spread<object> IncomingLinkValues { get; private set; }
public bool PatchHasChanged { get; private set; }
[Fragment]
public SharpRegion()
{
_sharedRecord = new SharpRegionRecord(42);
// Define no border control points initially
Inputs = Spread<BorderControlPointDescription>.Empty;
Outputs = Spread<BorderControlPointDescription>.Empty;
IncomingLinks = Spread<IncomingLinkDescription>.Empty;
InputValues = Spread<object>.Empty;
IncomingLinkValues = Spread<object>.Empty;
}
[Fragment]
public void Update(ICustomRegion input) {
// not sure what to do here
}
public ICustomRegionPatch CreateRegionPatch(
NodeContext context,
IReadOnlyList<object> initialInputs,
out Spread<object> initialOutputs
)
{
// Create the user's patch and inject the record
initialOutputs = Spread<object>.Empty;
// What to do here ???
return new SharpRegionPatch(_sharedRecord);
}
// Question: How to get actual patch in here?
private class SharpRegionPatch : ICustomRegionPatch
{
private readonly SharpRegionRecord _record;
public SharpRegionPatch(SharpRegionRecord record)
{
_record = record;
}
public ICustomRegionPatch Update(
IReadOnlyList<object> inputs,
out Spread<object> outputs,
IReadOnlyList<object> incomingLinks
)
{
// How to expose _record to nodes inside?
outputs = Spread<object>.Empty;
return this;
}
}
}
}
That’s about i can get:
and that’s a repo









