/// <summary> /// Clear a method call cache. /// </summary> /// <param name="methodInfo">The <see cref="MethodInfo"/> representing cached method.</param> public static void ClearCache(MethodInfo methodInfo) { if (methodInfo == null) { throw new ArgumentNullException("methodInfo"); } FieldInfo[] fields = methodInfo.DeclaringType.GetFields(BindingFlags.NonPublic | BindingFlags.Static); foreach (FieldInfo fieldInfo in fields) { if (fieldInfo.FieldType != typeof(CallMethodInfo)) { continue; } CallMethodInfo cmi = (CallMethodInfo)fieldInfo.GetValue(null); if (cmi != null && cmi.MethodInfo == methodInfo) { CleanupThread.ClearCache(cmi.MethodCallCache); break; } } }
/// <summary> /// Clear a method call cache. /// </summary> /// <param name="methodInfo">The <see cref="MethodInfo"/> representing cached method.</param> public static void ClearCache(MethodInfo methodInfo) { if (methodInfo == null) { throw new ArgumentNullException("methodInfo"); } var aspect = GetAspect(methodInfo); if (aspect != null) { CleanupThread.ClearCache(aspect.Cache); } }
/// <summary> /// Clear a method call cache. /// </summary> /// <param name="declaringType">The method declaring type.</param> /// <param name="methodName">The method name.</param> /// <param name="types">An array of <see cref="System.Type"/> objects representing /// the number, order, and type of the parameters for the method to get.-or- /// An empty array of the type <see cref="System.Type"/> (for example, <see cref="System.Type.EmptyTypes"/>) /// to get a method that takes no parameters.</param> /// <param name="values">An array of values of the parameters for the method to get</param> public static void ClearCache(Type declaringType, string methodName, Type[] types, object[] values) { var methodInfo = GetMethodInfo(declaringType, methodName, types); if (methodInfo == null) { throw new ArgumentNullException("methodInfo"); } var aspect = GetAspect(methodInfo); if (aspect != null) { CleanupThread.ClearCache(aspect.Cache, new CompoundValue(values)); } }
// BVChanges: ClearAllCache begin public static void ClearAllCache(MethodInfo methodInfo) { if (methodInfo == null) { throw new ArgumentNullException("methodInfo"); } lock (RegisteredAspects.SyncRoot) { foreach (CacheAspect aspect in RegisteredAspects) { if (aspect._methodInfo == methodInfo) { CleanupThread.ClearCache(aspect.Cache); } } } }
public static void ClearCache(Type declaringType) { if (declaringType == null) { throw new ArgumentNullException("declaringType"); } if (declaringType.IsAbstract) { declaringType = TypeBuilder.TypeFactory.GetType(declaringType); } lock (RegisteredAspects.SyncRoot) foreach (CacheAspect aspect in RegisteredAspects) { if (aspect._methodInfo.DeclaringType == declaringType) { CleanupThread.ClearCache(aspect.Cache); } } }
/// <summary> /// Clear all cached method calls. /// </summary> public static void ClearCache() { CleanupThread.ClearCache(); }