-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWebApiApplicationBuilder.cs
38 lines (32 loc) · 1.1 KB
/
WebApiApplicationBuilder.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using System;
using System.Collections.Generic;
using System.Web.Http;
namespace Microsoft.AspNet.Hosting.SystemWeb.WebApi
{
internal sealed class WebApiApplicationBuilder : IWebApiApplicationBuilder
{
private List<Action<IServiceProvider, HttpConfiguration>> actions = new List<Action<IServiceProvider, HttpConfiguration>>();
public WebApiApplicationBuilder(IServiceProvider services)
{
Services = services;
}
public IServiceProvider Services { get; }
public IWebApiApplicationBuilder Configure(Action<IServiceProvider, HttpConfiguration> configureDelegate)
{
actions.Add(configureDelegate);
return this;
}
public IWebApiApplicationBuilder Configure(Action<HttpConfiguration> configureDelegate)
{
actions.Add((_, c) => configureDelegate(c));
return this;
}
internal void Configure(HttpConfiguration config)
{
foreach (var action in actions)
{
action(this.Services, config);
}
}
}
}