public override void OnInvoke(MethodInterceptionArgs args) { base.OnInvoke(args); foreach (var mi in _affectedMethods) { MethodResultCache.GetCache(mi).ClearCachedResults(); } }
public sealed override void OnInvoke(MethodInterceptionArgs args) { var classType = Type.GetType(_className); _affectedMethods = classType.GetMethods(BindingFlags.Public | BindingFlags.Instance); foreach (var mi in _affectedMethods) { MethodResultCache.GetCache(mi.Name).ClearCachedResults(); } }
public sealed override void OnInvoke(MethodInterceptionArgs args) { var cache = MethodResultCache.GetCache(args.Method); var result = cache.GetCachedResult(args.Method.ToString()); if (result != null) { args.ReturnValue = result; return; } base.OnInvoke(args); cache.CacheCallResult(args.ReturnValue, args.Method.ToString(), _cacheRetainSeconds); }
/// <summary> /// Initializes a new instance of the <see cref="CacheInterceptor"/> class. /// </summary> /// <param name="methodResultCache">The <see cref="Caching.MethodResultCache"/>.</param> public CacheInterceptor( MethodResultCache methodResultCache ) { MethodResultCache = methodResultCache ?? throw new ArgumentNullException(nameof(methodResultCache)); }