This commit is contained in:
parent
46f5c107b8
commit
fa34ed249b
233 changed files with 4000 additions and 1396 deletions
|
|
@ -1,39 +0,0 @@
|
|||
using System;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.Http;
|
||||
|
||||
namespace Yavsc.Extensions {
|
||||
public static class AppBuilderExtensions {
|
||||
public static IApplicationBuilder UseWhen(this IApplicationBuilder app,
|
||||
Func<HttpContext, bool> condition, Action<IApplicationBuilder> configuration) {
|
||||
if (app == null) {
|
||||
throw new ArgumentNullException(nameof(app));
|
||||
}
|
||||
|
||||
if (condition == null) {
|
||||
throw new ArgumentNullException(nameof(condition));
|
||||
}
|
||||
|
||||
if (configuration == null) {
|
||||
throw new ArgumentNullException(nameof(configuration));
|
||||
}
|
||||
|
||||
var builder = app.New();
|
||||
configuration(builder);
|
||||
|
||||
return app.Use(next => {
|
||||
builder.Run(next);
|
||||
|
||||
var branch = builder.Build();
|
||||
|
||||
return context => {
|
||||
if (condition(context)) {
|
||||
return branch(context);
|
||||
}
|
||||
|
||||
return next(context);
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue