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
;
33 using System
.Security
.Principal
;
35 using Castle
.MVC
.States
;
38 namespace Castle
.MVC
.StatePersister
41 /// This class provides simple memory-based state persister for Windows Forms applications.
42 /// It is a singleton build by Castle IOC framework.
44 public class MemoryStatePersister
: IStatePersister
49 private IState _state
= null;
50 private IStateFactory _stateFactory
= null;
59 public MemoryStatePersister()
64 #region IStatePersister Members
69 public IStateFactory StateFactory
71 get{ return _stateFactory;}
72 set{ _stateFactory = value; }
76 /// Saves the State object in memory.
78 /// <param name="state">A valid State object.</param>
79 public void Save(IState state
)
85 /// Loads the saved state.
87 /// <returns>The saved state</returns>
92 _state
= _stateFactory
.Create();
100 /// <param name="state">The state to release.</param>
101 public void Release(IState state
)
103 _stateFactory
.Release(state
);