|
using System;
using System.Web;
using System.Reflection;
namespace BasePageFramework.SmartState
{
/// <summary>
/// Summary description for SmartApplicationBase.
/// </summary>
public class SmartApplicationBase : ISmartApplication
{
[field: NonSerialized()]
private HttpApplicationState _appState = null;
#region ISmartApplication Members
public void FlushAppState()
{
CheckInit();
_appState.Clear();
}
public void PersistToAppState()
{
CheckInit();
_appState.Lock();
//update the derived smartapplication object to the application state...
foreach(PropertyInfo inf in this.GetType().GetProperties())
this._appState[inf.Name] = inf.GetValue(this,null);
_appState.UnLock();
}
public void SetApplicationState(System.Web.HttpApplicationState state)
{
_appState = state;
//extract the values out of application state so our smart application object
//has everything it needs to be referenced in the page
_appState.Lock();
foreach(PropertyInfo inf in this.GetType().GetProperties())
inf.SetValue(this,this._appState[inf.Name],null);
_appState.UnLock();
}
private void CheckInit()
{
if(_appState == null)
throw new InvalidOperationException("The SmartApplicationState must be initialized before it is accessed");
}
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.