Using System;
Using System. Web;
Using System. Data;
Namespace SC
{
/// <Summary>
//**************************************/
// Description: cache class of DateTable.
// Attribute: name: the name of the cache. Write only
// Attribute: Values: read/write cached Values
// Method: CheckCache (): Check whether the cache exists. Return bool
// Method: MakeCacheEmpty (): Clear the cache
// Instance:
// Version 1.0
// Data = 2004-12-13
// Written By: Happy. net
//**************************************/
/// </Summary>
Public class Cache: System. Web. UI. Page
{
Private string name;
Private DataTable strvalue;
Public Cache (string setname)
{
Name = setname;
}
Private void SetCache (string setname, DataTable newvalue)
{
System. Web. HttpContext. Current. Application. Lock ();
System. Web. HttpContext. Current. Application [setname] = newvalue;
System. Web. HttpContext. Current. Application. UnLock ();
}
Public void MakeCacheEmpty () // clear the cache
{
System. Web. HttpContext. Current. Application. Lock ();
System. Web. HttpContext. Current. Application. Remove (name );
System. Web. HttpContext. Current. Application. UnLock ();
}
Public string Name // attribute: Name
{
Set
{
Name = value;
}
}
Public DataTable Values // attribute: cache Value
{
Get
{
Return (DataTable) System. Web. HttpContext. Current. Application [name];
}
Set
{
If (name! = "")
{
Strvalue = value;
SetCache (name, strvalue );
}
Else {}
}
}
Public bool CheckCache () // check the cache
{
Bool boolcheck = false;
If (System. Web. HttpContext. Current. Application [name]! = Null)
{
Boolcheck = true;
}
Return boolcheck;
}
}
}