forked from aspnet/AspNetWebStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHttpControllerSettings.cs
More file actions
86 lines (73 loc) · 2.56 KB
/
Copy pathHttpControllerSettings.cs
File metadata and controls
86 lines (73 loc) · 2.56 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Diagnostics.CodeAnalysis;
using System.Net.Http.Formatting;
using System.Web.Http.ModelBinding;
namespace System.Web.Http.Controllers
{
[SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable", Justification = "ServicesContainer is disposed with the configuration")]
public sealed class HttpControllerSettings
{
private MediaTypeFormatterCollection _formatters;
private ParameterBindingRulesCollection _parameterBindingRules;
private ServicesContainer _services;
private HttpConfiguration _configuration;
public HttpControllerSettings(HttpConfiguration configuration)
{
if (configuration == null)
{
throw Error.ArgumentNull("configuration");
}
_configuration = configuration;
}
public MediaTypeFormatterCollection Formatters
{
get
{
if (_formatters == null)
{
_formatters = new MediaTypeFormatterCollection(_configuration.Formatters);
}
return _formatters;
}
}
public ParameterBindingRulesCollection ParameterBindingRules
{
get
{
if (_parameterBindingRules == null)
{
_parameterBindingRules = new ParameterBindingRulesCollection();
foreach (var parameterBindingRule in _configuration.ParameterBindingRules)
{
_parameterBindingRules.Add(parameterBindingRule);
}
}
return _parameterBindingRules;
}
}
public ServicesContainer Services
{
get
{
if (_services == null)
{
_services = new ControllerServices(_configuration.Services);
}
return _services;
}
}
internal bool IsFormatterCollectionInitialized
{
get { return _formatters != null; }
}
internal bool IsParameterBindingRuleCollectionInitialized
{
get { return _parameterBindingRules != null; }
}
internal bool IsServiceCollectionInitialized
{
get { return _services != null; }
}
}
}