1
/* ****************************************************************************
3 * Copyright (c) Microsoft Corporation. All rights reserved.
5 * This software is subject to the Microsoft Public License (Ms-PL).
6 * A copy of the license can be found in the license.htm file included
7 * in this distribution.
9 * You must not remove this notice, or any other, from this software.
11 * ***************************************************************************/
13 namespace System
.Web
.Mvc
{
15 using System
.Diagnostics
.CodeAnalysis
;
16 using System
.Reflection
;
18 public abstract class ControllerDescriptor
: ICustomAttributeProvider
{
20 public virtual string ControllerName
{
22 string typeName
= ControllerType
.Name
;
23 if (typeName
.EndsWith("Controller", StringComparison
.OrdinalIgnoreCase
)) {
24 return typeName
.Substring(0, typeName
.Length
- "Controller".Length
);
31 public abstract Type ControllerType
{
35 public abstract ActionDescriptor
FindAction(ControllerContext controllerContext
, string actionName
);
37 public abstract ActionDescriptor
[] GetCanonicalActions();
39 [SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")]
40 public virtual object[] GetCustomAttributes(bool inherit
) {
41 return GetCustomAttributes(typeof(object), inherit
);
44 [SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")]
45 public virtual object[] GetCustomAttributes(Type attributeType
, bool inherit
) {
46 if (attributeType
== null) {
47 throw new ArgumentNullException("attributeType");
50 return (object[])Array
.CreateInstance(attributeType
, 0);
53 [SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")]
54 public virtual bool IsDefined(Type attributeType
, bool inherit
) {
55 if (attributeType
== null) {
56 throw new ArgumentNullException("attributeType");