66using System . Linq ;
77using System . Threading . Tasks ;
88using Microsoft . AspNet . Http ;
9+ using Microsoft . AspNet . Http . Infrastructure ;
910
1011namespace Microsoft . AspNet . Builder
1112{
@@ -15,17 +16,51 @@ public class Builder : IBuilder
1516
1617 public Builder ( IServiceProvider serviceProvider )
1718 {
19+ Properties = new Dictionary < string , object > ( ) ;
1820 ApplicationServices = serviceProvider ;
1921 }
2022
2123 private Builder ( Builder builder )
2224 {
23- ApplicationServices = builder . ApplicationServices ;
24- Server = builder . Server ;
25+ Properties = builder . Properties ;
2526 }
2627
27- public IServiceProvider ApplicationServices { get ; set ; }
28- public IServerInformation Server { get ; set ; }
28+ public IServiceProvider ApplicationServices
29+ {
30+ get
31+ {
32+ return GetProperty < IServiceProvider > ( Constants . BuilderProperties . ApplicationServices ) ;
33+ }
34+ set
35+ {
36+ SetProperty < IServiceProvider > ( Constants . BuilderProperties . ApplicationServices , value ) ;
37+ }
38+ }
39+
40+ public IServerInformation Server
41+ {
42+ get
43+ {
44+ return GetProperty < IServerInformation > ( Constants . BuilderProperties . ServerInformation ) ;
45+ }
46+ set
47+ {
48+ SetProperty < IServerInformation > ( Constants . BuilderProperties . ServerInformation , value ) ;
49+ }
50+ }
51+
52+ public IDictionary < string , object > Properties { get ; set ; }
53+
54+ private T GetProperty < T > ( string key )
55+ {
56+ object value ;
57+ return Properties . TryGetValue ( key , out value ) ? ( T ) value : default ( T ) ;
58+ }
59+
60+ private void SetProperty < T > ( string key , T value )
61+ {
62+ Properties [ key ] = value ;
63+ }
2964
3065 public IBuilder Use ( Func < RequestDelegate , RequestDelegate > middleware )
3166 {
0 commit comments