Skip to content

iudjin/ServiceComposer.AspNetCore

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ServiceComposer

ServiceComposer is a ViewModel Composition Gateway, for more details and the philosophy behind a Composition Gateway refer to the ViewModel Composition series of article available on milestone.topics.it

Usage

Create a new .NET Core console project and add a reference to the following Nuget packages:

  • Microsoft.AspNetCore
  • Microsoft.AspNetCore.Routing
  • ServiceComposer.AspNetCore

Configure the Startup class like following:

namespace CompositionGateway
{
    public class Startup
    {
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddRouting();
            services.AddViewModelComposition();
        }

        public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
        {
            app.RunCompositionGateway( routeBuilder=>
            {
                routeBuilder.MapComposableGet("{controller}/{id:int}");
            } );
        }
    }
}

Note: define routes so to match your project needs. ServiceComposer adds many MapComposable* extension methods to the IRouteBuilder interface, to map routes for every HTTP supported Verb.

Define one or more classes implementing either the IHandleRequests or the ISubscribeToCompositionEvents based on your needs.

Make sure the assemblies containing requests handlers and events subscribers are available to the composition gateway. By adding a reference or by simply dropping assemblies in the bin directory.

More details on how to implement IHandleRequests and ISubscribeToCompositionEvents are available in the following articles:

MVC and Web API support

For information on how to host the Composition Gateway in a ASP.Net COre MVC application, please, refer to the ServiceComposer.AspNetCore.Mvc package.

Icon

API by Guilherme Simoes from the Noun Project.

About

🧩 ServiceComposer, a ViewModel Composition API Gateway

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 99.6%
  • Other 0.4%