forked from haoduotnt/aspnetwebstack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAcceptVerbsAttribute.cs
More file actions
67 lines (58 loc) · 2.22 KB
/
AcceptVerbsAttribute.cs
File metadata and controls
67 lines (58 loc) · 2.22 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
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Net.Http;
using System.Web.Http.Controllers;
using System.Web.Http.Routing;
namespace System.Web.Http
{
/// <summary>
/// Specifies what HTTP methods an action supports.
/// </summary>
[SuppressMessage("Microsoft.Design", "CA1019:DefineAccessorsForAttributeArguments", Justification = "The accessor is exposed as an Collection<HttpMethod>.")]
[CLSCompliant(false)]
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
public sealed class AcceptVerbsAttribute : Attribute, IActionHttpMethodProvider, IHttpRouteInfoProvider
{
private readonly Collection<HttpMethod> _httpMethods;
/// <summary>
/// Initializes a new instance of the <see cref="AcceptVerbsAttribute" /> class.
/// </summary>
/// <param name="methods">The HTTP methods the action supports.</param>
public AcceptVerbsAttribute(params string[] methods)
{
_httpMethods = methods != null
? new Collection<HttpMethod>(methods.Select(method => HttpMethodHelper.GetHttpMethod(method)).ToArray())
: new Collection<HttpMethod>(new HttpMethod[0]);
}
internal AcceptVerbsAttribute(params HttpMethod[] methods)
{
_httpMethods = new Collection<HttpMethod>(methods);
}
/// <summary>
/// Gets the HTTP methods the action supports.
/// </summary>
public Collection<HttpMethod> HttpMethods
{
get
{
return _httpMethods;
}
}
/// <inheritdoc />
public string RouteName { get; set; }
/// <inheritdoc />
public int RouteOrder { get; set; }
/// <inheritdoc />
public string RouteTemplate { get; set; }
IEnumerable<HttpMethod> IHttpRouteInfoProvider.HttpMethods
{
get
{
return _httpMethods;
}
}
}
}