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 System
.Collections
;
32 using System
.Collections
.Specialized
;
34 using Castle
.MVC
.StatePersister
;
38 namespace Castle
.MVC
.States
41 /// Represent the base State.
42 /// You could inherit from this class when developing your state.
46 public abstract class BaseState
: DictionaryBase
, IState
50 /// Key used to retrieve the session.
52 public const string SESSION_KEY
= "_MVC_SESSION_STATE_";
56 private string _command
= string.Empty
;
58 private HybridDictionary _items
= new HybridDictionary();
59 private string _currentView
= string.Empty
;
60 private string _previousView
= string.Empty
;
61 IStatePersister _statePersister
= null;
74 #region IState members
77 /// A state persister provider.
79 public IStatePersister StatePersister
83 return _statePersister
;
87 _statePersister
= value;
92 /// Gets or sets the command id value. This value determines
93 /// which view is the next view in the navigation graph.
97 get{ return _command;}
98 set{ _command = value; }
102 /// Gets or sets the current view name.
104 public string CurrentView
106 get{ return _currentView; }
107 set{_currentView = value;}
111 /// Gets or sets the previous view.
113 public string PreviousView
115 get{ return _previousView; }
116 set{_previousView = value;}
120 /// Provides access to a dictionary of volative items.
122 public IDictionary Items
124 get{ return _items; }
132 /// Gets or sets an element saved on the state with the specified key.
134 public object this[ string key
]
136 set{this.Dictionary[ key ] = value;}
137 get{ return this.Dictionary[ key ]; }
153 _statePersister
.Save(this);