Apps.Contextsphere
1.3.4
Warning: Versions 7.0.0 or higher have breaking changes.
See the version list below for details.
dotnet add package Apps.Contextsphere --version 1.3.4
NuGet\Install-Package Apps.Contextsphere -Version 1.3.4
<PackageReference Include="Apps.Contextsphere" Version="1.3.4" />
paket add Apps.Contextsphere --version 1.3.4
#r "nuget: Apps.Contextsphere, 1.3.4"
// Install Apps.Contextsphere as a Cake Addin #addin nuget:?package=Apps.Contextsphere&version=1.3.4 // Install Apps.Contextsphere as a Cake Tool #tool nuget:?package=Apps.Contextsphere&version=1.3.4
Overview
Contextsphere facilitates clean separation of concerns by encapsulating app's functionalities in each its own context.
This design pattern is primarily aimed at front-end development usage. Whence a developer can write code in CQRS-oriented fashion without the bulk of using message buses/hubs.
Usage
Build your app's contexts in the root node class of your choice.
public class MyRootNode : IRootNode, IHandle<MyHandledObject1>, IHandleAsync<MyHandledAsyncObject1> ...
{
...
}
In the root node's constructor:
public MyRootNode(IContext context, IRootNodeObject rootNodeObject, IChildNode1Object childNode1Object, IChildNode2Object childNode2Object ...)
{
// 01. core app context
var rootContext = context.CreateContext(this, ContextType.Permanent);
// 02. first child context
rootContext.CreateContext(new MyChildNode1(childNode1Object), ContextType.Permanent)
// 03. second child context (subsequent creation can be chained)
.CreateContext(new MyChildNode2(childNode2Object), ContextType.Permanent)
...
this.Context = rootContext;
}
In the consuming classes, use dependency injection to access instance of IRootNode.
private readonly IRootNode root;
...
// send calls thru the root node.
MyObject? result1 = root.Context.Handle<MyObject>();
MyObject? result2 = await root.Context.HandleAsync<MyObject>();
MyObject? result3 = root.Context.Handle<MyParam, MyObject>(myParamInstance);
MyObject? result4 = await root.Context.HandleAsync<MyParam, MyObject>(myParamInstance);
// void or Task
root.Context.Handle<MyObject>(myObjectInstance);
await root.Context.HandleAsync<MyObject>(myObjectInstance);
// validation
bool isValid = root.Context.Validate<MyObject>(myObjectInstance);
bool isValid = await root.Context.ValidateAsync<MyObject>(myObjectInstance);
IValidationDetail<MyObject> validationDetails1 = root.Context.ValidateDetailed<MyObject>(myObjectInstance);
IValidationDetail<MyObject> validationDetails2 = await root.Context.ValidateDetailedAsync<MyObject>(myObjectInstance);
Context node classes provides the handling logic
public class MyContextNode1 : IHandleNoParamAsync<IEnumerable<MyObject>>, ...
{
public async Task<IEnumerable<MyObject>?> HandleAsync()
{
...
}
}
Concerns/Feedbacks?
You may reach me thru jakes_parane@hotmail.ph. Happy coding!
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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 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. |
-
net6.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated | |
---|---|---|---|
8.0.1 | 256 | 12/6/2023 | |
7.1.6 | 165 | 11/12/2023 | |
7.1.5 | 127 | 11/12/2023 | |
7.1.4 | 136 | 11/12/2023 | |
7.1.3 | 125 | 11/12/2023 | |
7.1.2 | 117 | 11/12/2023 | |
7.1.1 | 118 | 11/12/2023 | |
7.1.0 | 139 | 11/11/2023 | |
7.0.9 | 132 | 11/11/2023 | |
7.0.8 | 122 | 11/11/2023 | |
7.0.7 | 169 | 10/25/2023 | |
7.0.6 | 161 | 10/25/2023 | |
7.0.5 | 150 | 10/24/2023 | |
7.0.4 | 147 | 10/17/2023 | |
7.0.3 | 160 | 10/15/2023 | |
1.3.4 | 439 | 8/26/2022 |