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
|
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Reflection;
namespace System.Web.Mvc
{
public abstract class ControllerDescriptor : ICustomAttributeProvider, IUniquelyIdentifiable
{
private readonly Lazy<string> _uniqueId;
protected ControllerDescriptor()
{
_uniqueId = new Lazy<string>(CreateUniqueId);
}
public virtual string ControllerName
{
get
{
string typeName = ControllerType.Name;
if (typeName.EndsWith("Controller", StringComparison.OrdinalIgnoreCase))
{
return typeName.Substring(0, typeName.Length - "Controller".Length);
}
return typeName;
}
}
public abstract Type ControllerType { get; }
[SuppressMessage("Microsoft.Security", "CA2119:SealMethodsThatSatisfyPrivateInterfaces", Justification = "This is overridden elsewhere in System.Web.Mvc")]
public virtual string UniqueId
{
get { return _uniqueId.Value; }
}
private string CreateUniqueId()
{
return DescriptorUtil.CreateUniqueId(GetType(), ControllerName, ControllerType);
}
public abstract ActionDescriptor FindAction(ControllerContext controllerContext, string actionName);
public abstract ActionDescriptor[] GetCanonicalActions();
public virtual object[] GetCustomAttributes(bool inherit)
{
return GetCustomAttributes(typeof(object), inherit);
}
public virtual object[] GetCustomAttributes(Type attributeType, bool inherit)
{
if (attributeType == null)
{
throw new ArgumentNullException("attributeType");
}
return (object[])Array.CreateInstance(attributeType, 0);
}
public virtual IEnumerable<FilterAttribute> GetFilterAttributes(bool useCache)
{
return GetCustomAttributes(typeof(FilterAttribute), inherit: true).Cast<FilterAttribute>();
}
public virtual bool IsDefined(Type attributeType, bool inherit)
{
if (attributeType == null)
{
throw new ArgumentNullException("attributeType");
}
return false;
}
}
}
|