diff --git a/src/Cap.Consistency/Microsoft.AspNetCore.Builder/BuilderExtensions.cs b/src/Cap.Consistency/Microsoft.AspNetCore.Builder/BuilderExtensions.cs new file mode 100644 index 0000000..da6058f --- /dev/null +++ b/src/Cap.Consistency/Microsoft.AspNetCore.Builder/BuilderExtensions.cs @@ -0,0 +1,39 @@ +using System; +using Cap.Consistency; +using Microsoft.Extensions.DependencyInjection; + +// ReSharper disable once CheckNamespace +namespace Microsoft.AspNetCore.Builder +{ + /// + /// Consistence extensions for + /// + public static class BuilderExtensions + { + /// + /// Enables Consistence for the current application + /// + /// The instance this method extends. + /// The instance this method extends. + public static IApplicationBuilder UseConsistency(this IApplicationBuilder app) { + if (app == null) { + throw new ArgumentNullException(nameof(app)); + } + + var marker = app.ApplicationServices.GetService(); + + if (marker == null) { + throw new InvalidOperationException("Add Consistency must be called on the service collection."); + } + + var router = app.ApplicationServices.GetService(); + + var context = new TopicRouteContext(); + + router.RouteAsync(context); + + return app; + } + + } +} \ No newline at end of file