diff --git a/src/Neuroglia.Blazor.Dagre/GraphLib.cs b/src/Neuroglia.Blazor.Dagre/GraphLib.cs index da91ef47..0490333f 100644 --- a/src/Neuroglia.Blazor.Dagre/GraphLib.cs +++ b/src/Neuroglia.Blazor.Dagre/GraphLib.cs @@ -23,6 +23,8 @@ public class GraphLib(IJSObjectReference jsInstance) : IGraphLib, IAsyncDisposable, IDisposable { + readonly IJSObjectReference _jsInstance = jsInstance; + /// [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull)] [System.Text.Json.Serialization.JsonExtensionData] @@ -30,110 +32,218 @@ public class GraphLib(IJSObjectReference jsInstance) [Newtonsoft.Json.JsonExtensionData] public virtual IDictionary? Metadata { get; set; } - /// - /// The Graph js instance - /// - readonly IJSObjectReference _jsInstance = jsInstance; - /// public virtual async Task ChildrenAsync(string v) => await this._jsInstance.InvokeAsync("children", v); + /// - public virtual async Task FilterNodesAsync(Func filter) => (IGraphLib)await this._jsInstance.InvokeAsync("filterNodes", filter); + public virtual async Task FilterNodesAsync(Func filter) + { + await this._jsInstance.InvokeVoidAsync("filterNodes", filter); + return this; + } + /// public virtual async Task GraphAsync() => await this._jsInstance.InvokeAsync("graph"); + /// public virtual async Task HasEdgeAsync(string v, string w, string name) => await this._jsInstance.InvokeAsync("hasEdge", v, w, name); + /// public virtual async Task HasEdgeAsync(GraphLibEdge edge) => await this._jsInstance.InvokeAsync("hasEdge", edge); + /// public virtual async Task HasNodeAsync(string name) => await this._jsInstance.InvokeAsync("hasNode", name); + /// public virtual async Task EdgeAsync(string v, string w) => await this._jsInstance.InvokeAsync("edge", v, w); + /// public virtual async Task EdgeAsync(string v, string w, string name) => await this._jsInstance.InvokeAsync("edge", v, w, name); + /// public virtual async Task EdgeAsync(GraphLibEdge e) => await this._jsInstance.InvokeAsync("edge", e); + /// public virtual async Task EdgeCountAsync() => await this._jsInstance.InvokeAsync("edgeCount"); + /// public virtual async Task EdgesAsync() => await this._jsInstance.InvokeAsync("edges"); + /// public virtual async Task InEdgesAsync(string v, string w) => await this._jsInstance.InvokeAsync("inEdges", v, w); + /// public virtual async Task IsCompoundAsync() => await this._jsInstance.InvokeAsync("isCompound"); + /// public virtual async Task IsDirectedAsync() => await this._jsInstance.InvokeAsync("isDirected"); + /// public virtual async Task IsMultigraphAsync() => await this._jsInstance.InvokeAsync("isMultigraph"); + /// public virtual async Task InstanceAsync() => await Task.FromResult(this._jsInstance); + /// public virtual async Task NeighborsAsync(string v) => await this._jsInstance.InvokeAsync("neighbors", v); + /// public virtual async Task NodeAsync(string name) => await this._jsInstance.InvokeAsync("node", name); + /// public virtual async Task NodeCountAsync() => await this._jsInstance.InvokeAsync("nodeCount"); + /// public virtual async Task NodeEdgesAsync(string v, string w) => await this._jsInstance.InvokeAsync("nodeEdges", v, w); + /// public virtual async Task NodesAsync() => await this._jsInstance.InvokeAsync("nodes"); + /// public virtual async Task OutEdgesAsync(string v, string w) => await this._jsInstance.InvokeAsync("outEdges", v, w); + /// public virtual async Task ParentAsync(string v) => await this._jsInstance.InvokeAsync("parent", v); + /// public virtual async Task PredecessorsAsync(string v) => await this._jsInstance.InvokeAsync("predecessors", v); + /// - public virtual async Task RemoveEdgeAsync(GraphLibEdge edge) => (IGraphLib)await this._jsInstance.InvokeAsync("removeEdge", edge); + public virtual async Task RemoveEdgeAsync(GraphLibEdge edge) + { + await this._jsInstance.InvokeVoidAsync("removeEdge", edge); + return this; + } + /// - public virtual async Task RemoveEdgeAsync(string v, string w, string name) => (IGraphLib)await this._jsInstance.InvokeAsync("removeEdge", v, w, name); + public virtual async Task RemoveEdgeAsync(string v, string w, string name) + { + await this._jsInstance.InvokeVoidAsync("removeEdge", v, w, name); + return this; + } + /// - public virtual async Task RemoveNodeAsync(string name) => (IGraphLib)await this._jsInstance.InvokeAsync("removeNode", name); + public virtual async Task RemoveNodeAsync(string name) + { + await this._jsInstance.InvokeVoidAsync("removeNode", name); + return this; + } + /// - public virtual async Task SetDefaultEdgeLabelAsync(object label) => (IGraphLib)await this._jsInstance.InvokeAsync("setDefaultEdgeLabel", label); + public virtual async Task SetDefaultEdgeLabelAsync(object label) + { + await this._jsInstance.InvokeVoidAsync("setDefaultEdgeLabel", label); + return this; + } + /// - public virtual async Task SetDefaultEdgeLabelAsync(Func labelFn) => (IGraphLib)await this._jsInstance.InvokeAsync("setDefaultEdgeLabel", labelFn); + public virtual async Task SetDefaultEdgeLabelAsync(Func labelFn) + { + await this._jsInstance.InvokeVoidAsync("setDefaultEdgeLabel", labelFn); + return this; + } + /// - public virtual async Task SetDefaultNodeLabelAsync(object label) => (IGraphLib)await this._jsInstance.InvokeAsync("setDefaultNodeLabel", label); + public virtual async Task SetDefaultNodeLabelAsync(object label) + { + await this._jsInstance.InvokeVoidAsync("setDefaultNodeLabel", label); + return this; + } + /// - public virtual async Task SetDefaultNodeLabelAsync(Func labelFn) => (IGraphLib)await this._jsInstance.InvokeAsync("setDefaultNodeLabel", labelFn); + public virtual async Task SetDefaultNodeLabelAsync(Func labelFn) + { + await this._jsInstance.InvokeVoidAsync("setDefaultNodeLabel", labelFn); + return this; + } + /// - public virtual async Task SetGraphAsync(IDagreGraphConfig label) => (IGraphLib)await this._jsInstance.InvokeAsync("setGraph", label); + public virtual async Task SetGraphAsync(IDagreGraphConfig label) + { + await this._jsInstance.InvokeVoidAsync("setGraph", label); + return this; + } + /// - public virtual async Task SetEdgeAsync(string v, string w) => (IGraphLib)await this._jsInstance.InvokeAsync("setEdge", v, w); + public virtual async Task SetEdgeAsync(string v, string w) + { + await this._jsInstance.InvokeVoidAsync("setEdge", v, w); + return this; + } + /// - public virtual async Task SetEdgeAsync(string v, string w, object label) => (IGraphLib)await this._jsInstance.InvokeAsync("setEdge", v, w, label); + public virtual async Task SetEdgeAsync(string v, string w, object label) + { + await this._jsInstance.InvokeVoidAsync("setEdge", v, w, label); + return this; + } + /// - public virtual async Task SetEdgeAsync(string v, string w, object label, string name) => (IGraphLib)await this._jsInstance.InvokeAsync("setEdge", v, w, label, name); + public virtual async Task SetEdgeAsync(string v, string w, object label, string name) + { + await this._jsInstance.InvokeVoidAsync("setEdge", v, w, label, name); + return this; + } + /// - public virtual async Task SetEdgeAsync(GraphLibEdge edge, object label) => (IGraphLib)await this._jsInstance.InvokeAsync("setEdge", edge, label); + public virtual async Task SetEdgeAsync(GraphLibEdge edge, object label) + { + await this._jsInstance.InvokeVoidAsync("setEdge", edge, label); + return this; + } + /// - public virtual async Task SetNodeAsync(string name, object label) => (IGraphLib)await this._jsInstance.InvokeAsync("setNode", name, label); + public virtual async Task SetNodeAsync(string name, object label) + { + await this._jsInstance.InvokeVoidAsync("setNode", name, label); + return this; + } + /// - public virtual async Task SetNodesAsync(string[] names, object label) => (IGraphLib)await this._jsInstance.InvokeAsync("setNodes", names, label); + public virtual async Task SetNodesAsync(string[] names, object label) + { + await this._jsInstance.InvokeVoidAsync("setNodes", names, label); + return this; + } + /// - public virtual async Task SetParentAsync(string v, string p) => (IGraphLib)await this._jsInstance.InvokeAsync("setParent", v, p); + public virtual async Task SetParentAsync(string v, string p) + { + await this._jsInstance.InvokeVoidAsync("setParent", v, p); + return this; + } + /// - public virtual async Task SetPathAsync(string[] nodes, object label) => (IGraphLib)await this._jsInstance.InvokeAsync("setPath", nodes, label); + public virtual async Task SetPathAsync(string[] nodes, object label) + { + await this._jsInstance.InvokeVoidAsync("setPath", nodes, label); + return this; + } + /// public virtual async Task SinksAsync() => await this._jsInstance.InvokeAsync("sinks"); + /// public virtual async Task SourcesAsync() => await this._jsInstance.InvokeAsync("sources"); + /// public virtual async Task SuccessorsAsync(string v) => await this._jsInstance.InvokeAsync("successors", v); + /// public void Dispose() { Dispose(disposing: true); GC.SuppressFinalize(this); } + /// public async ValueTask DisposeAsync() { await DisposeAsyncCore().ConfigureAwait(false); GC.SuppressFinalize(this); } + /// protected virtual void Dispose(bool disposing) { if (disposing) @@ -142,6 +252,7 @@ protected virtual void Dispose(bool disposing) } } + /// protected virtual async ValueTask DisposeAsyncCore() { if (this._jsInstance is not null)