Unreified 1.2.0
dotnet add package Unreified --version 1.2.0
NuGet\Install-Package Unreified -Version 1.2.0
<PackageReference Include="Unreified" Version="1.2.0" />
<PackageVersion Include="Unreified" Version="1.2.0" />
<PackageReference Include="Unreified" />
paket add Unreified --version 1.2.0
#r "nuget: Unreified, 1.2.0"
#:package Unreified@1.2.0
#addin nuget:?package=Unreified&version=1.2.0
#tool nuget:?package=Unreified&version=1.2.0
Unreified
Unreified is a dependency injection container and in-process pipeline orchestrator for .NET
It is designed to help manage dependencies that will be created as a part of a longer or more complex process and to facilitate flow of data from one step to the next.
Installing Unreified
via command line dotnet add package Unreified
or via NuGet Install-Package Unreified
First class support for passing data between steps
No more using global variables or IMemoryCache
to pass things between different services. Just return the thing. That's it.
async static Task<Func<string>> LongOperation()
{
await Task.Delay(1000);
return () => "hello there";
}
void SayHello(Func<string> getMessage) => Console.WriteLine(getMessage());
var executor = new Executor();
await executor.Execute(Step.FromMethod(LongOperation), CancellationToken.None);
// the result of LongOperation (Func<string>) is now available in a container and will be injected to SayHello
await executor.Execute(Step.FromMethod(SayHello), CancellationToken.None);
Automatic orchestration and dependency resolution
So one of your execution steps returns a thing, that thing is a dependency for a factory, and that factory returns something for the next step. Sounds awful to do with a "standard" container. With Unreified it is easy:
async static Task<object> LongOperation()
{
await Task.Delay(1000);
return new Func<string>(() => "hello there");
}
var executor = new Executor();
executor.AddSteps(
Step.FromMethod(LongOperation), // the first step
Step.FromMethod((string mes) => Console.WriteLine(mes))); // the next step
// the factory. the order of registration does not matter
executor.RegisterTransientFactory<string>((Func<string> func) => func());
// Notice that LongOperation returns Task<object>.
// The dependency for the string factory will be materialized during execution, as a result of one of the steps
// and then it will be properly registered as a delegate of type Func<string>
await executor.RunAll(maxDegreeOfParallelism: 1, CancellationToken.None);
Parallel execution
If your execution steps do not depend on one another, you can execute them simultaneously
record class Dependency1();
record class Dependency2();
Task<Dependency1> IndependentStep1() => Task.FromResult(new Dependency1());
Task<Dependency2> IndependentStep2() => Task.FromResult(new Dependency2());
string FirstStepWithDependencies(Dependency1 d1, Dependency2 d2) => "";
void SecondStepWithDependencies(string s) => {};
var executor = new Executor();
// These steps can be registered in ANY order. Here they happen to be registered in execution order,
// but that's simply to make it easier to understand what was the author's intention
executor.AddSteps(
Step.FromMethod(IndependentStep1),
Step.FromMethod(IndependentStep2),
Step.FromMethod(FirstStepWithDependencies),
Step.FromMethod(SecondStepWithDependencies));
await executor.RunAll(maxDegreeOfParallelism: 5, CancellationToken.None);
// Look here, this is important ^
This code will execute in parallel IndependentStep1
and IndependentStep2
, then it will run FirstStepWithDependencies
, and the last thing will be SecondStepWithDependencies
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. 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 is compatible. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. 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.0
- Microsoft.Bcl.AsyncInterfaces (>= 6.0.0)
- Microsoft.Extensions.ObjectPool (>= 6.0.0)
-
net6.0
- Microsoft.Extensions.ObjectPool (>= 6.0.0)
-
net8.0
- Microsoft.Extensions.ObjectPool (>= 6.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
v1.1.0:
Added support for ValueTask.
Added option to instantiate a service.
Added default method body for IExecutable<T> interface.
v1.2.0:
Fixed step instantiation when multiple steps tried to execute the same singleton factory simultaneously.
List of missing dependecies is now distinct