Placing IServiceProvider on IBuilder
Replaces concept of features/items on builder instance for now
This commit is contained in:
parent
f9d29fd8aa
commit
e2f45c59ea
|
|
@ -4,13 +4,12 @@ namespace Microsoft.AspNet.Abstractions
|
|||
{
|
||||
public interface IBuilder
|
||||
{
|
||||
IServiceProvider ServiceProvider { get; set; }
|
||||
|
||||
IBuilder Use(Func<RequestDelegate, RequestDelegate> middleware);
|
||||
IBuilder Run(RequestDelegate handler);
|
||||
|
||||
IBuilder New();
|
||||
RequestDelegate Build();
|
||||
|
||||
object GetItem(Type type);
|
||||
void SetItem(Type type, object feature);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,56 +1,20 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Abstractions;
|
||||
using Microsoft.AspNet.FeatureModel;
|
||||
|
||||
namespace Microsoft.AspNet.PipelineCore
|
||||
{
|
||||
public class Builder : IBuilder
|
||||
{
|
||||
private readonly IFeatureCollection _interfaces;
|
||||
private readonly IDictionary<string, object> _properties;
|
||||
private readonly IList<Func<RequestDelegate, RequestDelegate>> _components = new List<Func<RequestDelegate, RequestDelegate>>();
|
||||
|
||||
public Builder()
|
||||
public Builder(IServiceProvider serviceProvider)
|
||||
{
|
||||
_interfaces = new FeatureCollection();
|
||||
_properties = new Dictionary<string, object>();
|
||||
ServiceProvider = serviceProvider;
|
||||
}
|
||||
|
||||
public Builder(IFeatureCollection interfaces, IDictionary<string, object> properties)
|
||||
{
|
||||
_interfaces = interfaces;
|
||||
_properties = properties;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_interfaces.Dispose();
|
||||
}
|
||||
|
||||
public virtual object GetItem(Type key)
|
||||
{
|
||||
object value;
|
||||
return _interfaces.TryGetValue(key, out value);
|
||||
}
|
||||
|
||||
public virtual void SetItem(Type key, object value)
|
||||
{
|
||||
_interfaces[key] = value;
|
||||
}
|
||||
|
||||
public virtual object GetItem(string key)
|
||||
{
|
||||
object value;
|
||||
return _properties.TryGetValue(key, out value);
|
||||
}
|
||||
|
||||
public virtual void SetItem(string key, object value)
|
||||
{
|
||||
_properties[key] = value;
|
||||
}
|
||||
public IServiceProvider ServiceProvider { get; set; }
|
||||
|
||||
public IBuilder Use(Func<RequestDelegate, RequestDelegate> middleware)
|
||||
{
|
||||
|
|
@ -65,7 +29,7 @@ namespace Microsoft.AspNet.PipelineCore
|
|||
|
||||
public IBuilder New()
|
||||
{
|
||||
return new Builder(_interfaces, _properties);
|
||||
return new Builder(ServiceProvider);
|
||||
}
|
||||
|
||||
public RequestDelegate Build()
|
||||
|
|
|
|||
Loading…
Reference in New Issue