Added ability to order the execution of dictionary adapter behaviors.
[castle.git] / Experiments / Attic / MVC / Castle.MVC / StatePersister / MemoryStatePersister.cs
blob93bf0ec7c24de17bd0daaf7e40ff46a9ecde589d
1 #region Apache Notice
2 /*****************************************************************************
3 *
4 * Castle.MVC
5 *
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
9 *
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 ********************************************************************************/
19 #endregion
21 #region Autors
23 /************************************************
24 * Gilles Bayon
25 *************************************************/
26 #endregion
28 #region Using
30 using System;
31 using System.Collections;
32 using System.Collections.Specialized;
33 using System.Security.Principal;
35 using Castle.MVC.States;
36 #endregion
38 namespace Castle.MVC.StatePersister
40 /// <summary>
41 /// This class provides simple memory-based state persister for Windows Forms applications.
42 /// It is a singleton build by Castle IOC framework.
43 /// </summary>
44 public class MemoryStatePersister : IStatePersister
47 #region Fields
49 private IState _state = null;
50 private IStateFactory _stateFactory = null;
52 #endregion
54 #region Constructors
56 /// <summary>
57 /// Constructor
58 /// </summary>
59 public MemoryStatePersister()
62 #endregion
64 #region IStatePersister Members
66 /// <summary>
67 /// State factory
68 /// </summary>
69 public IStateFactory StateFactory
71 get{ return _stateFactory;}
72 set{ _stateFactory = value; }
75 /// <summary>
76 /// Saves the State object in memory.
77 /// </summary>
78 /// <param name="state">A valid State object.</param>
79 public void Save(IState state)
81 _state = state;
84 /// <summary>
85 /// Loads the saved state.
86 /// </summary>
87 /// <returns>The saved state</returns>
88 public IState Load()
90 if (_state==null)
92 _state = _stateFactory.Create();
94 return _state;
97 /// <summary>
98 /// Release a state
99 /// </summary>
100 /// <param name="state">The state to release.</param>
101 public void Release(IState state)
103 _stateFactory.Release(state);
104 _state = null;
106 #endregion