Flush (work in progress)
[mono.git] / mcs / class / System.Web.Mvc2 / System.Web.Mvc / ControllerDescriptor.cs
1 /* ****************************************************************************\r
2  *\r
3  * Copyright (c) Microsoft Corporation. All rights reserved.\r
4  *\r
5  * This software is subject to the Microsoft Public License (Ms-PL). \r
6  * A copy of the license can be found in the license.htm file included \r
7  * in this distribution.\r
8  *\r
9  * You must not remove this notice, or any other, from this software.\r
10  *\r
11  * ***************************************************************************/\r
12 \r
13 namespace System.Web.Mvc {\r
14     using System;\r
15     using System.Reflection;\r
16 \r
17     public abstract class ControllerDescriptor : ICustomAttributeProvider {\r
18 \r
19         public virtual string ControllerName {\r
20             get {\r
21                 string typeName = ControllerType.Name;\r
22                 if (typeName.EndsWith("Controller", StringComparison.OrdinalIgnoreCase)) {\r
23                     return typeName.Substring(0, typeName.Length - "Controller".Length);\r
24                 }\r
25 \r
26                 return typeName;\r
27             }\r
28         }\r
29 \r
30         public abstract Type ControllerType {\r
31             get;\r
32         }\r
33 \r
34         public abstract ActionDescriptor FindAction(ControllerContext controllerContext, string actionName);\r
35 \r
36         public abstract ActionDescriptor[] GetCanonicalActions();\r
37 \r
38         public virtual object[] GetCustomAttributes(bool inherit) {\r
39             return GetCustomAttributes(typeof(object), inherit);\r
40         }\r
41 \r
42         public virtual object[] GetCustomAttributes(Type attributeType, bool inherit) {\r
43             if (attributeType == null) {\r
44                 throw new ArgumentNullException("attributeType");\r
45             }\r
46 \r
47             return (object[])Array.CreateInstance(attributeType, 0);\r
48         }\r
49 \r
50         public virtual bool IsDefined(Type attributeType, bool inherit) {\r
51             if (attributeType == null) {\r
52                 throw new ArgumentNullException("attributeType");\r
53             }\r
54 \r
55             return false;\r
56         }\r
57 \r
58     }\r
59 }\r