Explorar el Código

refactor

master
yangxiaodong hace 7 años
padre
commit
e136a05663
Se han modificado 1 ficheros con 39 adiciones y 0 borrados
  1. +39
    -0
      src/Cap.Consistency/Microsoft.AspNetCore.Builder/BuilderExtensions.cs

+ 39
- 0
src/Cap.Consistency/Microsoft.AspNetCore.Builder/BuilderExtensions.cs Ver fichero

@@ -0,0 +1,39 @@
using System;
using Cap.Consistency;
using Microsoft.Extensions.DependencyInjection;

// ReSharper disable once CheckNamespace
namespace Microsoft.AspNetCore.Builder
{
/// <summary>
/// Consistence extensions for <see cref="IApplicationBuilder"/>
/// </summary>
public static class BuilderExtensions
{
///<summary>
/// Enables Consistence for the current application
/// </summary>
/// <param name="app">The <see cref="IApplicationBuilder"/> instance this method extends.</param>
/// <returns>The <see cref="IApplicationBuilder"/> instance this method extends.</returns>
public static IApplicationBuilder UseConsistency(this IApplicationBuilder app) {
if (app == null) {
throw new ArgumentNullException(nameof(app));
}
var marker = app.ApplicationServices.GetService<ConsistencyMarkerService>();
if (marker == null) {
throw new InvalidOperationException("Add Consistency must be called on the service collection.");
}

var router = app.ApplicationServices.GetService<ITopicRouteHandler>();

var context = new TopicRouteContext();

router.RouteAsync(context);

return app;
}

}
}

Cargando…
Cancelar
Guardar