2 /*****************************************************************************
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 ********************************************************************************/
23 /************************************************
25 *************************************************/
31 using Castle
.MVC
.Configuration
;
32 using Castle
.MVC
.Navigation
;
33 using Castle
.MVC
.States
;
37 namespace Castle
.MVC
.Controllers
40 /// Abstract base class to control the navigation between views.
41 /// You must inherit from this class when developing yours controllers.
43 public abstract class Controller
: IController
47 private INavigator _navigator
= null;
48 private string _nextViewToDisplay
= null;
54 /// Default constructor
61 #region IController Members
65 /// The next view to display.
67 public string NextView
69 get { return _nextViewToDisplay; }
70 set { _nextViewToDisplay = value; }
74 /// Get the user process state.
78 get { return _navigator.CurrentState; }
82 /// The navigator coordinates the interactions of views and controllers
84 public INavigator Navigator
86 get { return _navigator; }
87 set { _navigator = value;}
95 /// Calls the Navigate method on the appropriate navigator
96 /// and navigate to the next view according to the config file.
98 public void Navigate()
100 this.State
.PreviousView
= this.State
.CurrentView
;
101 this.State
.CurrentView
= ConfigUtil
.Settings
.GetNextView(this.State
.CurrentView
, this.State
.Command
);
102 _navigator
.Navigate();
106 /// Calls the Navigate method on the appropriate navigator
108 /// <param name="view">the Next View To Display</param>
109 public void Navigate(string view
)
111 this.State
.PreviousView
= this.State
.CurrentView
;
112 this.State
.CurrentView
= view
;
113 _navigator
.Navigate();