首页 新闻 会员 周边

关于unity cache aop.

0
悬赏园豆:5 [已解决问题] 解决于 2010-11-17 13:33

第一次执行的时候没有问题。
当我执行缓存对象的时候,就报了个类型转换错误。
也就是说容器并没有返回我要的对象,而是直接返回了个TransparentProxyMethodReturn对象。
google一圈没找到结果,请同行赐教。

 

public class CacheHandler : ICallHandler
{
/// <summary>
/// 缓存key
/// </summary>
public string Key { get; set; }
public int Order { get; set; }
private static volatile System.Web.Caching.Cache _webCache = System.Web.HttpRuntime.Cache;
public IMethodReturn Invoke(IMethodInvocation input, GetNextHandlerDelegate getNext)
{
object obj = _webCache.Get(Key);
if (obj != null)
return input.CreateMethodReturn(obj, input.Arguments);

var result
= getNext().Invoke(input, getNext);
_webCache.Insert(Key, result);
return result;
}
}

 

demo 在这里
http://files.cnblogs.com/yuanhuaming/UnityAop.rar

 

疯流成性的主页 疯流成性 | 初学一级 | 园豆:3
提问于:2010-11-16 17:31
< >
分享
最佳答案
0

return input.CreateMethodReturn(obj, input.Arguments);

改成 return obj as IMethodReturn;

收获园豆:5
喝苍蝇的可乐 | 菜鸟二级 |园豆:230 | 2010-11-17 13:25
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册