diff --git a/src/Microsoft.AspNet.Http/IBuilder.cs b/src/Microsoft.AspNet.Http/IBuilder.cs index 6a2c1b3197..1673390e07 100644 --- a/src/Microsoft.AspNet.Http/IBuilder.cs +++ b/src/Microsoft.AspNet.Http/IBuilder.cs @@ -2,17 +2,22 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Collections.Generic; namespace Microsoft.AspNet.Builder { public interface IBuilder { IServiceProvider ApplicationServices { get; set; } + IServerInformation Server { get; set; } + IDictionary Properties { get; set; } + IBuilder Use(Func middleware); IBuilder New(); + RequestDelegate Build(); } } diff --git a/src/Microsoft.AspNet.PipelineCore/Builder.cs b/src/Microsoft.AspNet.PipelineCore/Builder.cs index fae10cf6a2..12a95ebd8f 100644 --- a/src/Microsoft.AspNet.PipelineCore/Builder.cs +++ b/src/Microsoft.AspNet.PipelineCore/Builder.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNet.Http; +using Microsoft.AspNet.Http.Infrastructure; namespace Microsoft.AspNet.Builder { @@ -15,17 +16,51 @@ namespace Microsoft.AspNet.Builder public Builder(IServiceProvider serviceProvider) { + Properties = new Dictionary(); ApplicationServices = serviceProvider; } private Builder(Builder builder) { - ApplicationServices = builder.ApplicationServices; - Server = builder.Server; + Properties = builder.Properties; } - public IServiceProvider ApplicationServices { get; set; } - public IServerInformation Server { get; set; } + public IServiceProvider ApplicationServices + { + get + { + return GetProperty(Constants.BuilderProperties.ApplicationServices); + } + set + { + SetProperty(Constants.BuilderProperties.ApplicationServices, value); + } + } + + public IServerInformation Server + { + get + { + return GetProperty(Constants.BuilderProperties.ServerInformation); + } + set + { + SetProperty(Constants.BuilderProperties.ServerInformation, value); + } + } + + public IDictionary Properties { get; set; } + + private T GetProperty(string key) + { + object value; + return Properties.TryGetValue(key, out value) ? (T)value : default(T); + } + + private void SetProperty(string key, T value) + { + Properties[key] = value; + } public IBuilder Use(Func middleware) { diff --git a/src/Microsoft.AspNet.PipelineCore/Infrastructure/Constants.cs b/src/Microsoft.AspNet.PipelineCore/Infrastructure/Constants.cs index 9404c79c70..c918c4de33 100644 --- a/src/Microsoft.AspNet.PipelineCore/Infrastructure/Constants.cs +++ b/src/Microsoft.AspNet.PipelineCore/Infrastructure/Constants.cs @@ -25,5 +25,11 @@ namespace Microsoft.AspNet.Http.Infrastructure internal const string Expires = "Expires"; internal const string WebSocketSubProtocols = "Sec-WebSocket-Protocol"; } + + internal static class BuilderProperties + { + internal static string ServerInformation = "server.Information"; + internal static string ApplicationServices = "application.Services"; + } } }