예제 #1
0
        /// <summary>
        /// Gets the MethodInfo based on the given signature.
        /// </summary>
        /// <param name="type">The type where the method is.</param>
        /// <param name="methodInfoCache">The cache of method infos.</param>
        /// <param name="signature">The signature of the method to look up.</param>
        /// <returns>Method info.</returns>
        public static MethodInfo GetMethodInfo(Type type, IDictionary <string, MethodInfo> methodInfoCache, string signature)
        {
            MethodInfo methodInfo;

            if (!methodInfoCache.TryGetValue(signature, out methodInfo))
            {
                methodInfo = WrapperUtilities.GetMethodInfo(type, signature);
                methodInfoCache[signature] = methodInfo;
            }

            return(methodInfo);
        }
예제 #2
0
        /// <summary>
        /// Gets the type handle for a given name of the type.
        /// </summary>
        /// <param name="typeName">Name of the type.</param>
        /// <param name="assemblyName">Name of the assembly.</param>
        /// <param name="typeCache">The cache of known type handles</param>
        /// <returns>Runtime type handle.</returns>
        public static Type GetTypeFromCache(string typeName, string assemblyName, IDictionary <string, Type> typeCache)
        {
            string cacheKey = assemblyName + "." + typeName;
            Type   type;

            if (!typeCache.TryGetValue(cacheKey, out type))
            {
                type = WrapperUtilities.GetTypeFromAssembly(typeName, assemblyName);
                typeCache[cacheKey] = type;
            }

            return(type);
        }