60 lines
1.9 KiB
C#
60 lines
1.9 KiB
C#
/* ****************************************************************************
|
|
*
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
*
|
|
* This software is subject to the Microsoft Public License (Ms-PL).
|
|
* A copy of the license can be found in the license.htm file included
|
|
* in this distribution.
|
|
*
|
|
* You must not remove this notice, or any other, from this software.
|
|
*
|
|
* ***************************************************************************/
|
|
|
|
namespace System.Web.Mvc {
|
|
using System;
|
|
using System.Reflection;
|
|
|
|
public abstract class ControllerDescriptor : ICustomAttributeProvider {
|
|
|
|
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;
|
|
}
|
|
|
|
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 bool IsDefined(Type attributeType, bool inherit) {
|
|
if (attributeType == null) {
|
|
throw new ArgumentNullException("attributeType");
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
}
|
|
}
|