OpenAuth.Net/Infrastructure/Cache/HttpApplicationContext.cs

65 lines
1.4 KiB
C#
Raw Normal View History

2016-07-08 22:52:40 +08:00
// ***********************************************************************
2016-11-17 19:48:12 +08:00
// Assembly : Helper
// Author : Administrator
// Created : 09-21-2016
2016-07-08 22:52:40 +08:00
//
2016-11-17 19:48:12 +08:00
// Last Modified By : Administrator
// Last Modified On : 11-09-2016
2016-07-08 22:52:40 +08:00
// Contact :
2016-11-17 19:48:12 +08:00
// File: HttpApplicationContext.cs
2016-07-08 22:52:40 +08:00
// ***********************************************************************
using System;
using System.Web;
2016-11-17 19:48:12 +08:00
namespace Helper.Cache
2016-07-08 22:52:40 +08:00
{
2016-11-17 19:48:12 +08:00
/// <summary>
/// 基于HttpApplication的存储
/// <para>李玉宝新增于2016-11-09 9:30:51</para>
/// </summary>
public sealed class HttpApplicationContext : ICacheContext
2016-07-08 22:52:40 +08:00
{
public override void Init()
{
}
public override T Get<T>(string key)
{
return (T) HttpContext.Current.Application[key];
}
public override bool Set<T>(string key, T t)
{
try
{
HttpContext.Current.Application[key] = t;
return true;
}
catch (Exception)
{
return false;
}
}
public override bool Remove(string key)
{
try
{
HttpContext.Current.Application[key] = null;
return true;
}
catch (Exception)
{
return false;
}
}
public override void Dispose()
{
}
}
}