Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Simple command pattern framework for .NET Core and ASP.NET Core

License

NotificationsYou must be signed in to change notification settings

odds-bods/EasyCommand

Repository files navigation

Installation

EasyCommand.AspNetCore is in pre-release and is available as aNuGet package.

What's this?

EasyCommand trivialises the use of the command pattern in .NET Core and ASP.NET Core.

this.ExecuteAsync(this.Command<GetCommand>());

It is an opinionated, light, command pattern framework.

publicclassGetCommandParamId:AsyncAspCommand<int,string>{protectedoverrideTask<string>ExecuteCommandAsync(intrequest){returnTask.FromResult("value");}}

You can execute commands straight from an ASP.NET Core controller (so you can better componentise your code) and this can assist with separating application protocol and business logic.

[HttpGet]publicasyncTask<ActionResult<IEnumerable<string>>>Get(){returnawaitthis.ExecuteAsync(this.Command<GetCommand>());}

You can call commands from other commands.

publicclassFirstCommand:AsyncAspCommand<int,int>{protectedoverrideasyncTask<int>ExecuteCommandAsync(intrequest){returnawaitthis.ExecuteAsync(this.Command<SecondCommand>(),request);}}

As with ASP.NET controllers, EasyCommand supports the .NET Core service dependency registration and injection model.

publicclassSecondCommand:AsyncAspCommand<int,int>{privatereadonlyIRandomServicerandomService;publicSecondCommand(IRandomServicerandomService){this.randomService=randomService;}protectedoverrideTask<int>ExecuteCommandAsync(intrequest){returnTask.FromResult(request+randomService.Next());}}

About

Simple command pattern framework for .NET Core and ASP.NET Core

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp