private static MethodInfoCollection GetMethodCollection(MethodCache cache, Type type, string name) { MethodInfoCollection info; if (!cache.TryGetValue(name, out info)) { return(null); } return(info); }
public ServiceMethod Resolve(InvocationTarget target) { if (target == null) { throw new ArgumentNullException(nameof(target), "An invocation target must be specified."); } if (target.IsWeaklyTyped) { ServiceMethod[] methods; if (string.IsNullOrEmpty(target.TypeName)) { SimpleMethodCache.TryGetValue(target.MethodName, out methods); } else { TypedMethodCache.TryGetValue(GetTypedMethodKey(target.TypeName, target.MethodName), out methods); } if (methods == null) { throw new MissingMethodException("The specified request contains an unrecognized interface name, method name."); } if (methods.Length > 1) { throw new ProgrammaticException("Weakly-typed requests cannot be used for methods with more than one overload (including methods that are only differentiated by letter case)", unencrypted: new Tags { { "method", target.MethodName }, { "type", target.TypeName } }); } return(methods.Single()); } else { if (string.IsNullOrEmpty(target.TypeName) || string.IsNullOrEmpty(target.MethodName) || target.ParameterTypes == null) { throw new ArgumentException("The specified invocation target is invalid.", nameof(target)); } MethodCache.TryGetValue(target, out ServiceMethod method); if (method == null) { throw new MissingMethodException("The specified request contains an unrecognized interface name, method name or method overload."); } return(method); } }
private static MethodInfo TryFindInterfaceMethodMatching( Type interfaceType, string methodName, Type returnType, Type[] parameterTypes) { lock (MethodCache) { PopulateMethodCacheIfNecessaryFor(interfaceType); return(MethodCache.TryGetValue(Tuple.Create( interfaceType, methodName, returnType, parameterTypes), out var result) ? result : null); } }