Skip to content
This repository was archived by the owner on Nov 20, 2018. It is now read-only.

Commit 335895d

Browse files
committed
#122 - Rename IBuilder to IApplicationBuilder.
1 parent ba4f44c commit 335895d

File tree

10 files changed

+47
-48
lines changed

10 files changed

+47
-48
lines changed

src/Microsoft.AspNet.Http/Extensions/MapExtensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public static class MapExtensions
1717
/// <param name="pathMatch">The path to match</param>
1818
/// <param name="configuration">The branch to take for positive path matches</param>
1919
/// <returns></returns>
20-
public static IBuilder Map([NotNull] this IBuilder app, [NotNull] string pathMatch, [NotNull] Action<IBuilder> configuration)
20+
public static IApplicationBuilder Map([NotNull] this IApplicationBuilder app, [NotNull] string pathMatch, [NotNull] Action<IApplicationBuilder> configuration)
2121
{
2222
return Map(app, new PathString(pathMatch), configuration);
2323
}
@@ -30,15 +30,15 @@ public static IBuilder Map([NotNull] this IBuilder app, [NotNull] string pathMat
3030
/// <param name="pathMatch">The path to match</param>
3131
/// <param name="configuration">The branch to take for positive path matches</param>
3232
/// <returns></returns>
33-
public static IBuilder Map([NotNull] this IBuilder app, PathString pathMatch, [NotNull] Action<IBuilder> configuration)
33+
public static IApplicationBuilder Map([NotNull] this IApplicationBuilder app, PathString pathMatch, [NotNull] Action<IApplicationBuilder> configuration)
3434
{
3535
if (pathMatch.HasValue && pathMatch.Value.EndsWith("/", StringComparison.Ordinal))
3636
{
3737
throw new ArgumentException("The path must not end with a '/'", "pathMatch");
3838
}
3939

4040
// create branch
41-
IBuilder branchBuilder = app.New();
41+
var branchBuilder = app.New();
4242
configuration(branchBuilder);
4343
var branch = branchBuilder.Build();
4444

src/Microsoft.AspNet.Http/Extensions/MapWhenExtensions.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ public static class MapWhenExtensions
2323
/// <param name="predicate">Invoked with the request environment to determine if the branch should be taken</param>
2424
/// <param name="configuration">Configures a branch to take</param>
2525
/// <returns></returns>
26-
public static IBuilder MapWhen([NotNull] this IBuilder app, [NotNull] Predicate predicate, [NotNull] Action<IBuilder> configuration)
26+
public static IApplicationBuilder MapWhen([NotNull] this IApplicationBuilder app, [NotNull] Predicate predicate, [NotNull] Action<IApplicationBuilder> configuration)
2727
{
2828
// create branch
29-
IBuilder branchBuilder = app.New();
29+
var branchBuilder = app.New();
3030
configuration(branchBuilder);
3131
var branch = branchBuilder.Build();
3232

@@ -46,10 +46,10 @@ public static IBuilder MapWhen([NotNull] this IBuilder app, [NotNull] Predicate
4646
/// <param name="predicate">Invoked asynchronously with the request environment to determine if the branch should be taken</param>
4747
/// <param name="configuration">Configures a branch to take</param>
4848
/// <returns></returns>
49-
public static IBuilder MapWhenAsync([NotNull] this IBuilder app, [NotNull] PredicateAsync predicate, [NotNull] Action<IBuilder> configuration)
49+
public static IApplicationBuilder MapWhenAsync([NotNull] this IApplicationBuilder app, [NotNull] PredicateAsync predicate, [NotNull] Action<IApplicationBuilder> configuration)
5050
{
5151
// create branch
52-
IBuilder branchBuilder = app.New();
52+
var branchBuilder = app.New();
5353
configuration(branchBuilder);
5454
var branch = branchBuilder.Build();
5555

src/Microsoft.AspNet.Http/Extensions/RunExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Microsoft.AspNet.Builder
88
{
99
public static class RunExtensions
1010
{
11-
public static void Run([NotNull] this IBuilder app, [NotNull] RequestDelegate handler)
11+
public static void Run([NotNull] this IApplicationBuilder app, [NotNull] RequestDelegate handler)
1212
{
1313
app.Use(_ => handler);
1414
}

src/Microsoft.AspNet.Http/Extensions/UseExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public static class UseExtensions
1515
/// <param name="app"></param>
1616
/// <param name="middleware">A function that handles the request or calls the given next function.</param>
1717
/// <returns></returns>
18-
public static IBuilder Use(this IBuilder app, Func<HttpContext, Func<Task>, Task> middleware)
18+
public static IApplicationBuilder Use(this IApplicationBuilder app, Func<HttpContext, Func<Task>, Task> middleware)
1919
{
2020
return app.Use(next =>
2121
{

src/Microsoft.AspNet.Http/IBuilder.cs renamed to src/Microsoft.AspNet.Http/IApplicationBuilder.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@
66

77
namespace Microsoft.AspNet.Builder
88
{
9-
public interface IBuilder
9+
public interface IApplicationBuilder
1010
{
1111
IServiceProvider ApplicationServices { get; set; }
1212

1313
IServerInformation Server { get; set; }
1414

1515
IDictionary<string, object> Properties { get; set; }
1616

17-
IBuilder Use(Func<RequestDelegate, RequestDelegate> middleware);
17+
IApplicationBuilder Use(Func<RequestDelegate, RequestDelegate> middleware);
1818

19-
IBuilder New();
19+
IApplicationBuilder New();
2020

2121
RequestDelegate Build();
2222
}

src/Microsoft.AspNet.Owin/OwinExtensions.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace Microsoft.AspNet.Builder
2323

2424
public static class OwinExtensions
2525
{
26-
public static AddMiddleware UseOwin(this IBuilder builder)
26+
public static AddMiddleware UseOwin(this IApplicationBuilder builder)
2727
{
2828
AddMiddleware add = middleware =>
2929
{
@@ -58,17 +58,17 @@ public static AddMiddleware UseOwin(this IBuilder builder)
5858
return add;
5959
}
6060

61-
public static IBuilder UseOwin(this IBuilder builder, Action<AddMiddleware> pipeline)
61+
public static IApplicationBuilder UseOwin(this IApplicationBuilder builder, Action<AddMiddleware> pipeline)
6262
{
6363
pipeline(builder.UseOwin());
6464
return builder;
6565
}
6666

67-
public static IBuilder UseBuilder(this AddMiddleware app)
67+
public static IApplicationBuilder UseBuilder(this AddMiddleware app)
6868
{
6969
// Adapt WebSockets by default.
7070
app(OwinWebSocketAcceptAdapter.AdaptWebSockets);
71-
var builder = new Builder(serviceProvider: null);
71+
var builder = new ApplicationBuilder(serviceProvider: null);
7272

7373
CreateMiddleware middleware = CreateMiddlewareFactory(exit =>
7474
{
@@ -111,7 +111,7 @@ private static CreateMiddleware CreateMiddlewareFactory(Func<RequestDelegate, Re
111111
};
112112
}
113113

114-
public static AddMiddleware UseBuilder(this AddMiddleware app, Action<IBuilder> pipeline)
114+
public static AddMiddleware UseBuilder(this AddMiddleware app, Action<IApplicationBuilder> pipeline)
115115
{
116116
var builder = app.UseBuilder();
117117
pipeline(builder);

src/Microsoft.AspNet.PipelineCore/Builder.cs renamed to src/Microsoft.AspNet.PipelineCore/ApplicationBuilder.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,21 @@
55
using System.Collections.Generic;
66
using System.Linq;
77
using System.Threading.Tasks;
8-
using Microsoft.AspNet.Http;
98
using Microsoft.AspNet.Http.Infrastructure;
109

1110
namespace Microsoft.AspNet.Builder
1211
{
13-
public class Builder : IBuilder
12+
public class ApplicationBuilder : IApplicationBuilder
1413
{
1514
private readonly IList<Func<RequestDelegate, RequestDelegate>> _components = new List<Func<RequestDelegate, RequestDelegate>>();
1615

17-
public Builder(IServiceProvider serviceProvider)
16+
public ApplicationBuilder(IServiceProvider serviceProvider)
1817
{
1918
Properties = new Dictionary<string, object>();
2019
ApplicationServices = serviceProvider;
2120
}
2221

23-
private Builder(Builder builder)
22+
private ApplicationBuilder(ApplicationBuilder builder)
2423
{
2524
Properties = builder.Properties;
2625
}
@@ -62,15 +61,15 @@ private void SetProperty<T>(string key, T value)
6261
Properties[key] = value;
6362
}
6463

65-
public IBuilder Use(Func<RequestDelegate, RequestDelegate> middleware)
64+
public IApplicationBuilder Use(Func<RequestDelegate, RequestDelegate> middleware)
6665
{
6766
_components.Add(middleware);
6867
return this;
6968
}
7069

71-
public IBuilder New()
70+
public IApplicationBuilder New()
7271
{
73-
return new Builder(this);
72+
return new ApplicationBuilder(this);
7473
}
7574

7675
public RequestDelegate Build()

test/Microsoft.AspNet.Http.Tests/MapPathMiddlewareTests.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace Microsoft.AspNet.Builder.Extensions
1313
{
1414
public class MapPathMiddlewareTests
1515
{
16-
private static readonly Action<IBuilder> ActionNotImplemented = new Action<IBuilder>(_ => { throw new NotImplementedException(); });
16+
private static readonly Action<IApplicationBuilder> ActionNotImplemented = new Action<IApplicationBuilder>(_ => { throw new NotImplementedException(); });
1717

1818
private static Task Success(HttpContext context)
1919
{
@@ -23,7 +23,7 @@ private static Task Success(HttpContext context)
2323
return Task.FromResult<object>(null);
2424
}
2525

26-
private static void UseSuccess(IBuilder app)
26+
private static void UseSuccess(IApplicationBuilder app)
2727
{
2828
app.Run(Success);
2929
}
@@ -33,16 +33,16 @@ private static Task NotImplemented(HttpContext context)
3333
throw new NotImplementedException();
3434
}
3535

36-
private static void UseNotImplemented(IBuilder app)
36+
private static void UseNotImplemented(IApplicationBuilder app)
3737
{
3838
app.Run(NotImplemented);
3939
}
4040

4141
[Fact]
4242
public void NullArguments_ArgumentNullException()
4343
{
44-
var builder = new Builder(serviceProvider: null);
45-
var noMiddleware = new Builder(serviceProvider: null).Build();
44+
var builder = new ApplicationBuilder(serviceProvider: null);
45+
var noMiddleware = new ApplicationBuilder(serviceProvider: null).Build();
4646
var noOptions = new MapOptions();
4747
// TODO: [NotNull] Assert.Throws<ArgumentNullException>(() => builder.Map(null, ActionNotImplemented));
4848
// TODO: [NotNull] Assert.Throws<ArgumentNullException>(() => builder.Map("/foo", (Action<IBuilder>)null));
@@ -61,7 +61,7 @@ public void NullArguments_ArgumentNullException()
6161
public void PathMatchFunc_BranchTaken(string matchPath, string basePath, string requestPath)
6262
{
6363
HttpContext context = CreateRequest(basePath, requestPath);
64-
IBuilder builder = new Builder(serviceProvider: null);
64+
var builder = new ApplicationBuilder(serviceProvider: null);
6565
builder.Map(matchPath, UseSuccess);
6666
var app = builder.Build();
6767
app.Invoke(context).Wait();
@@ -82,7 +82,7 @@ public void PathMatchFunc_BranchTaken(string matchPath, string basePath, string
8282
public void PathMatchAction_BranchTaken(string matchPath, string basePath, string requestPath)
8383
{
8484
HttpContext context = CreateRequest(basePath, requestPath);
85-
IBuilder builder = new Builder(serviceProvider: null);
85+
var builder = new ApplicationBuilder(serviceProvider: null);
8686
builder.Map(matchPath, subBuilder => subBuilder.Run(Success));
8787
var app = builder.Build();
8888
app.Invoke(context).Wait();
@@ -98,7 +98,7 @@ public void PathMatchAction_BranchTaken(string matchPath, string basePath, strin
9898
[InlineData("/foo/cho/")]
9999
public void MatchPathWithTrailingSlashThrowsException(string matchPath)
100100
{
101-
Should.Throw<ArgumentException>(() => new Builder(serviceProvider: null).Map(matchPath, map => { }).Build());
101+
Should.Throw<ArgumentException>(() => new ApplicationBuilder(serviceProvider: null).Map(matchPath, map => { }).Build());
102102
}
103103

104104
[Theory]
@@ -112,7 +112,7 @@ public void MatchPathWithTrailingSlashThrowsException(string matchPath)
112112
public void PathMismatchFunc_PassedThrough(string matchPath, string basePath, string requestPath)
113113
{
114114
HttpContext context = CreateRequest(basePath, requestPath);
115-
IBuilder builder = new Builder(serviceProvider: null);
115+
var builder = new ApplicationBuilder(serviceProvider: null);
116116
builder.Map(matchPath, UseNotImplemented);
117117
builder.Run(Success);
118118
var app = builder.Build();
@@ -134,7 +134,7 @@ public void PathMismatchFunc_PassedThrough(string matchPath, string basePath, st
134134
public void PathMismatchAction_PassedThrough(string matchPath, string basePath, string requestPath)
135135
{
136136
HttpContext context = CreateRequest(basePath, requestPath);
137-
IBuilder builder = new Builder(serviceProvider: null);
137+
var builder = new ApplicationBuilder(serviceProvider: null);
138138
builder.Map(matchPath, UseNotImplemented);
139139
builder.Run(Success);
140140
var app = builder.Build();
@@ -148,7 +148,7 @@ public void PathMismatchAction_PassedThrough(string matchPath, string basePath,
148148
[Fact]
149149
public void ChainedRoutes_Success()
150150
{
151-
IBuilder builder = new Builder(serviceProvider: null);
151+
var builder = new ApplicationBuilder(serviceProvider: null);
152152
builder.Map("/route1", map =>
153153
{
154154
map.Map((string)"/subroute1", UseSuccess);

test/Microsoft.AspNet.Http.Tests/MapPredicateMiddlewareTests.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ private static Task Success(HttpContext context)
2626
return Task.FromResult<object>(null);
2727
}
2828

29-
private static void UseSuccess(IBuilder app)
29+
private static void UseSuccess(IApplicationBuilder app)
3030
{
3131
app.Run(Success);
3232
}
@@ -36,7 +36,7 @@ private static Task NotImplemented(HttpContext context)
3636
throw new NotImplementedException();
3737
}
3838

39-
private static void UseNotImplemented(IBuilder app)
39+
private static void UseNotImplemented(IApplicationBuilder app)
4040
{
4141
app.Run(NotImplemented);
4242
}
@@ -64,8 +64,8 @@ private Task<bool> FalsePredicateAsync(HttpContext context)
6464
[Fact]
6565
public void NullArguments_ArgumentNullException()
6666
{
67-
var builder = new Builder(serviceProvider: null);
68-
var noMiddleware = new Builder(serviceProvider: null).Build();
67+
var builder = new ApplicationBuilder(serviceProvider: null);
68+
var noMiddleware = new ApplicationBuilder(serviceProvider: null).Build();
6969
var noOptions = new MapWhenOptions();
7070
// TODO: [NotNull] Assert.Throws<ArgumentNullException>(() => builder.MapWhen(null, UseNotImplemented));
7171
// TODO: [NotNull] Assert.Throws<ArgumentNullException>(() => builder.MapWhen(NotImplementedPredicate, (Action<IBuilder>)null));
@@ -82,7 +82,7 @@ public void NullArguments_ArgumentNullException()
8282
public void PredicateTrue_BranchTaken()
8383
{
8484
HttpContext context = CreateRequest();
85-
IBuilder builder = new Builder(serviceProvider: null);
85+
var builder = new ApplicationBuilder(serviceProvider: null);
8686
builder.MapWhen(TruePredicate, UseSuccess);
8787
var app = builder.Build();
8888
app.Invoke(context).Wait();
@@ -94,7 +94,7 @@ public void PredicateTrue_BranchTaken()
9494
public void PredicateTrueAction_BranchTaken()
9595
{
9696
HttpContext context = CreateRequest();
97-
IBuilder builder = new Builder(serviceProvider: null);
97+
var builder = new ApplicationBuilder(serviceProvider: null);
9898
builder.MapWhen(TruePredicate, UseSuccess);
9999
var app = builder.Build();
100100
app.Invoke(context).Wait();
@@ -106,7 +106,7 @@ public void PredicateTrueAction_BranchTaken()
106106
public void PredicateFalseAction_PassThrough()
107107
{
108108
HttpContext context = CreateRequest();
109-
IBuilder builder = new Builder(serviceProvider: null);
109+
var builder = new ApplicationBuilder(serviceProvider: null);
110110
builder.MapWhen(FalsePredicate, UseNotImplemented);
111111
builder.Run(Success);
112112
var app = builder.Build();
@@ -119,7 +119,7 @@ public void PredicateFalseAction_PassThrough()
119119
public void PredicateAsyncTrueAction_BranchTaken()
120120
{
121121
HttpContext context = CreateRequest();
122-
IBuilder builder = new Builder(serviceProvider: null);
122+
var builder = new ApplicationBuilder(serviceProvider: null);
123123
builder.MapWhenAsync(TruePredicateAsync, UseSuccess);
124124
var app = builder.Build();
125125
app.Invoke(context).Wait();
@@ -131,7 +131,7 @@ public void PredicateAsyncTrueAction_BranchTaken()
131131
public void PredicateAsyncFalseAction_PassThrough()
132132
{
133133
HttpContext context = CreateRequest();
134-
IBuilder builder = new Builder(serviceProvider: null);
134+
var builder = new ApplicationBuilder(serviceProvider: null);
135135
builder.MapWhenAsync(FalsePredicateAsync, UseNotImplemented);
136136
builder.Run(Success);
137137
var app = builder.Build();
@@ -143,7 +143,7 @@ public void PredicateAsyncFalseAction_PassThrough()
143143
[Fact]
144144
public void ChainedPredicates_Success()
145145
{
146-
IBuilder builder = new Builder(serviceProvider: null);
146+
var builder = new ApplicationBuilder(serviceProvider: null);
147147
builder.MapWhen(TruePredicate, map1 =>
148148
{
149149
map1.MapWhen((Predicate)FalsePredicate, UseNotImplemented);
@@ -160,7 +160,7 @@ public void ChainedPredicates_Success()
160160
[Fact]
161161
public void ChainedPredicatesAsync_Success()
162162
{
163-
IBuilder builder = new Builder(serviceProvider: null);
163+
var builder = new ApplicationBuilder(serviceProvider: null);
164164
builder.MapWhenAsync(TruePredicateAsync, map1 =>
165165
{
166166
map1.MapWhenAsync((PredicateAsync)FalsePredicateAsync, UseNotImplemented);

test/Microsoft.AspNet.PipelineCore.Tests/BuilderTests.cs renamed to test/Microsoft.AspNet.PipelineCore.Tests/ApplicationBuilderTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66

77
namespace Microsoft.AspNet.Builder.Tests
88
{
9-
public class BuilderTests
9+
public class ApplicationBuilderTests
1010
{
1111
[Fact]
1212
public void BuildReturnsCallableDelegate()
1313
{
14-
var builder = new Builder(null);
14+
var builder = new ApplicationBuilder(null);
1515
var app = builder.Build();
1616

1717
var mockHttpContext = new Moq.Mock<HttpContext>();

0 commit comments

Comments
 (0)