forked from aspnet/AspNetWebStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApiParameterDescription.cs
More file actions
71 lines (63 loc) · 2.44 KB
/
Copy pathApiParameterDescription.cs
File metadata and controls
71 lines (63 loc) · 2.44 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
// 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.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Web.Http.Controllers;
using System.Web.Http.Internal;
namespace System.Web.Http.Description
{
/// <summary>
/// Describes a parameter on the API defined by relative URI path and HTTP method.
/// </summary>
public class ApiParameterDescription
{
/// <summary>
/// Gets or sets the name.
/// </summary>
/// <value>
/// The name.
/// </value>
public string Name { get; set; }
/// <summary>
/// Gets or sets the documentation.
/// </summary>
/// <value>
/// The documentation.
/// </value>
public string Documentation { get; set; }
/// <summary>
/// Gets or sets the source of the parameter. It may come from the request URI, request body or other places.
/// </summary>
/// <value>
/// The source.
/// </value>
public ApiParameterSource Source { get; set; }
/// <summary>
/// Gets or sets the parameter descriptor.
/// </summary>
/// <value>
/// The parameter descriptor. <see langref="null"/> if (and only if) a <see cref="ApiParameterSource.FromUri"/>
/// parameter is declared in route template but unused in the API. Never-<see langref="null"/> for other
/// sources.
/// </value>
/// <remarks>
/// For more information on the <see langref="null"/> case, search <see cref="ApiExplorer"/> for "undeclared"
/// route parameter handling.
/// </remarks>
public HttpParameterDescriptor ParameterDescriptor { get; set; }
internal IEnumerable<PropertyInfo> GetBindableProperties()
{
return GetBindableProperties(ParameterDescriptor.ParameterType);
}
internal bool CanConvertPropertiesFromString()
{
return GetBindableProperties().All(p => TypeHelper.CanConvertFromString(p.PropertyType));
}
internal static IEnumerable<PropertyInfo> GetBindableProperties(Type type)
{
return type.GetProperties(BindingFlags.Instance | BindingFlags.Public)
.Where(p => p.GetGetMethod() != null && p.GetSetMethod() != null);
}
}
}