示例#1
0
        public override void OnInvoke(MethodInterceptionArgs args)
        {
            base.OnInvoke(args);

            foreach (var mi in _affectedMethods)
            {
                MethodResultCache.GetCache(mi).ClearCachedResults();
            }
        }
示例#2
0
        public static MethodResultCache GetCache(string methodName)
        {
            if (MethodCaches.ContainsKey(methodName))
            {
                return(MethodCaches[methodName]);
            }
            var cache = new MethodResultCache(methodName);

            MethodCaches.Add(methodName, cache);
            return(cache);
        }
示例#3
0
        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();
            }
        }
示例#4
0
        public sealed override void OnInvoke(MethodInterceptionArgs args)
        {
            var cache     = MethodResultCache.GetCache(args.Method);
            var arguments = args.Arguments.Union(new[] { WindowsIdentity.GetCurrent().Name }).ToList();
            var result    = cache.GetCachedResult(arguments);

            if (result != null)
            {
                args.ReturnValue = result;
                return;
            }

            base.OnInvoke(args);

            cache.CacheCallResult(args.ReturnValue, arguments, _cacheRetainSeconds);
        }