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
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 manyMapComposable*
extension methods to theIRouteBuilder
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:
For information on how to host the Composition Gateway in a ASP.Net COre MVC application, please, refer to the ServiceComposer.AspNetCore.Mvc
package.
API by Guilherme Simoes from the Noun Project.