Pārlūkot izejas kodu

refactor

master
yangxiaodong pirms 7 gadiem
vecāks
revīzija
e136a05663
1 mainītis faili ar 39 papildinājumiem un 0 dzēšanām
  1. +39
    -0
      src/Cap.Consistency/Microsoft.AspNetCore.Builder/BuilderExtensions.cs

+ 39
- 0
src/Cap.Consistency/Microsoft.AspNetCore.Builder/BuilderExtensions.cs Parādīt failu

@@ -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;
}

}
}

Notiek ielāde…
Atcelt
Saglabāt