-
Notifications
You must be signed in to change notification settings - Fork 9.8k
/
MigrationsEndPointExtensions.cs
51 lines (46 loc) · 2.31 KB
/
MigrationsEndPointExtensions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore;
using Microsoft.Extensions.Options;
// ReSharper disable once CheckNamespace
namespace Microsoft.AspNetCore.Builder
{
/// <summary>
/// <see cref="IApplicationBuilder"/> extension methods for the <see cref="MigrationsEndPointMiddleware"/>.
/// </summary>
public static class MigrationsEndPointExtensions
{
/// <summary>
/// Processes requests to execute migrations operations. The middleware will listen for requests made to <see cref="MigrationsEndPointOptions.DefaultPath"/>.
/// </summary>
/// <param name="app">The <see cref="IApplicationBuilder"/> to register the middleware with.</param>
/// <returns>The same <see cref="IApplicationBuilder"/> instance so that multiple calls can be chained.</returns>
public static IApplicationBuilder UseMigrationsEndPoint(this IApplicationBuilder app)
{
if (app == null)
{
throw new ArgumentNullException(nameof(app));
}
return app.UseMigrationsEndPoint(new MigrationsEndPointOptions());
}
/// <summary>
/// Processes requests to execute migrations operations. The middleware will listen for requests to the path configured in <paramref name="options"/>.
/// </summary>
/// <param name="app">The <see cref="IApplicationBuilder"/> to register the middleware with.</param>
/// <param name="options">An action to set the options for the middleware.</param>
/// <returns>The same <see cref="IApplicationBuilder"/> instance so that multiple calls can be chained.</returns>
public static IApplicationBuilder UseMigrationsEndPoint(this IApplicationBuilder app, MigrationsEndPointOptions options)
{
if (app == null)
{
throw new ArgumentNullException(nameof(app));
}
if (options == null)
{
throw new ArgumentNullException(nameof(options));
}
return app.UseMiddleware<MigrationsEndPointMiddleware>(Options.Create(options));
}
}
}