using system;
using system.web;
using system.data;

namespace sc
{
 /// <summary>
 //**************************************/
 // 说明:datetable的缓存类。
 //  属性:name:缓存的名称。只写
 //  属性:values:缓存的值 读写
 //  方法:checkcache():检查是否有缓存。返回bool
 //  方法:makecacheempty():清空缓存
 //  实例:
 //version:1.0
 //data=2004-12-13
 //written by: 幸福.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()//清空缓存
  {
   system.web.httpcontext.current.application.lock();
   system.web.httpcontext.current.application.remove(name);
   system.web.httpcontext.current.application.unlock();

  }

  public string name//属性:名称
  {
   set
   {
    name=value;
   }
  }

  public datatable values//属性:缓存值
  {
   get
   {
    return (datatable)system.web.httpcontext.current.application[name];
   }
   set
   {
    if (name!=””)
    {
     
     strvalue=value;
     setcache(name,strvalue);
    }
    else{}
    
   }

  }
  
  public bool  checkcache()//检查缓存
  {
   bool boolcheck=false;
   if (system.web.httpcontext.current.application[name]!=null)
   {
    boolcheck=true;
   }
   
   return boolcheck;
  }

 }
}