在ASP.NET的单次请求中使用Singleton模式

代码:

public class SingletonPerRequest
{
    
public static SingletonPerRequest Current
    {
        
get
        {
            
return (HttpContext.Current.Items["SingletonPerRequest"??
                (HttpContext.Current.Items[
"SingletonPerRequest"= 
                
new SingletonPerRequest())) as SingletonPerRequest;

        }
    }
}

 

 

详见:http://dotnetslackers.com/community/blogs/simoneb/archive/2006/08/21/The-ASP.NET-Singleton_2D00_per_2D00_Request-pattern.aspx

 

 

 

posted @ 2011-04-27 09:05  程序员海风  阅读(353)  评论(0编辑  收藏  举报