Remove excessive shortcut key matching in ToolStrip
[mono.git] / mcs / class / System.Web.Mvc / System.Web.Mvc / ControllerBase.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.Collections.Generic;\r
16     using System.Diagnostics.CodeAnalysis;\r
17     using System.Web.Routing;\r
18 \r
19     public abstract class ControllerBase : MarshalByRefObject, IController {\r
20 \r
21         private TempDataDictionary _tempDataDictionary;\r
22         private bool _validateRequest = true;\r
23         private IDictionary<string, ValueProviderResult> _valueProvider;\r
24         private ViewDataDictionary _viewDataDictionary;\r
25 \r
26         public ControllerContext ControllerContext {\r
27             get;\r
28             set;\r
29         }\r
30 \r
31         [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly",\r
32             Justification = "This property is settable so that unit tests can provide mock implementations.")]\r
33         public TempDataDictionary TempData {\r
34             get {\r
35                 if (_tempDataDictionary == null) {\r
36                     _tempDataDictionary = new TempDataDictionary();\r
37                 }\r
38                 return _tempDataDictionary;\r
39             }\r
40             set {\r
41                 _tempDataDictionary = value;\r
42             }\r
43         }\r
44 \r
45         public bool ValidateRequest {\r
46             get {\r
47                 return _validateRequest;\r
48             }\r
49             set {\r
50                 _validateRequest = value;\r
51             }\r
52         }\r
53 \r
54         [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly",\r
55             Justification = "This property is settable so that unit tests can provide mock implementations.")]\r
56         public IDictionary<string, ValueProviderResult> ValueProvider {\r
57             get {\r
58                 if (_valueProvider == null) {\r
59                     _valueProvider = new ValueProviderDictionary(ControllerContext);\r
60                 }\r
61                 return _valueProvider;\r
62             }\r
63             set {\r
64                 _valueProvider = value;\r
65             }\r
66         }\r
67 \r
68         [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly",\r
69             Justification = "This property is settable so that unit tests can provide mock implementations.")]\r
70         public ViewDataDictionary ViewData {\r
71             get {\r
72                 if (_viewDataDictionary == null) {\r
73                     _viewDataDictionary = new ViewDataDictionary();\r
74                 }\r
75                 return _viewDataDictionary;\r
76             }\r
77             set {\r
78                 _viewDataDictionary = value;\r
79             }\r
80         }\r
81 \r
82         protected virtual void Execute(RequestContext requestContext) {\r
83             if (requestContext == null) {\r
84                 throw new ArgumentNullException("requestContext");\r
85             }\r
86 \r
87             Initialize(requestContext);\r
88             ExecuteCore();\r
89         }\r
90 \r
91         protected abstract void ExecuteCore();\r
92 \r
93         protected virtual void Initialize(RequestContext requestContext) {\r
94             ControllerContext = new ControllerContext(requestContext, this);\r
95         }\r
96 \r
97         #region IController Members\r
98         void IController.Execute(RequestContext requestContext) {\r
99             Execute(requestContext);\r
100         }\r
101         #endregion\r
102     }\r
103 }\r