LanceC.DependencyGraph
1.0.1
See the version list below for details.
dotnet add package LanceC.DependencyGraph --version 1.0.1
NuGet\Install-Package LanceC.DependencyGraph -Version 1.0.1
<PackageReference Include="LanceC.DependencyGraph" Version="1.0.1" />
paket add LanceC.DependencyGraph --version 1.0.1
#r "nuget: LanceC.DependencyGraph, 1.0.1"
// Install LanceC.DependencyGraph as a Cake Addin #addin nuget:?package=LanceC.DependencyGraph&version=1.0.1 // Install LanceC.DependencyGraph as a Cake Tool #tool nuget:?package=LanceC.DependencyGraph&version=1.0.1
DependencyGraph
This package is used to execute processes that are dependent on the execution of at least one other process. The engine builds a directed graph of provided executions, checks for cycles, performs a reverse topological sort, and executes the results in order.
Install
Install the NuGet package into your project.
PM> Install-Package LanceC.DependencyGraph
$ dotnet add package LanceC.DependencyGraph
Usage
- The dependency graph classes must first be registered for DI.
- Processes to be executed need to implement
IDependencyExecution<T>
.- The identifier type has to implement
IEquatable<T>
. - It is recommended to register each execution in the DI container and retrieve them as an
IEnumerable<IDependencyExecution<T>>
.
- The identifier type has to implement
Registration
services.AddDependencyGraph();
Execution
The sample below uses string
as the identifier type for the executions.
public class Foo
{
private readonly IDependencyExecutionEngine<string> _dependencyExecutionEngine;
private readonly IEnumerable<IDependencyExecution<string>> _executions;
public Foo(
IDependencyExecutionEngine<string> dependencyExecutionEngine,
IEnumerable<IDependencyExecution<string>> executions)
{
_dependencyExecutionEngine = dependencyExecutionEngine;
_executions = executions;
}
public async Task Execute(CancellationToken cancellationToken)
{
await _dependencyExecutionEngine.ExecuteAll(executions, cancellationToken);
}
}
Errors
- In the case where a circular dependency chain is found (e.g.
A
has a dependency onB
andB
has a dependency onA
), aCircularDependenciesException
is thrown upon engine execution.- The exception contains the text representations of the strongly-connected cycles (e.g. 'A' → 'B').
- In the case where multiple executions contain the same key, a
DuplicateKeyException
is thrown upon engine execution.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Initial release.
1.0.1 patch:
- Throw exception when execution collection contains duplicate keys.
- Support executions with return results.