예제 #1
0
            public (MethodInfo?method, object[]? parameters) GetMethodToCall(IServiceProvider services, object[] requiredInputs, object[] optionalInputs)
            {
                if (services is null)
                {
                    throw new ArgumentNullException(nameof(services));
                }

                if (requiredInputs is null)
                {
                    throw new ArgumentNullException(nameof(requiredInputs));
                }

                if (optionalInputs is null)
                {
                    throw new ArgumentNullException(nameof(optionalInputs));
                }

                var callKey = new InputParameterTypesKey(
                    requiredInputs.Select(e => e.GetType()).ToArray(),
                    optionalInputs.Select(e => e.GetType()).ToArray());

                var signature = cache.GetOrAdd(callKey, CreateSignature);

                if (signature.IsEmpty)
                {
                    return(null, null);
                }

                return(signature.Method, signature.CreateParameters(services, requiredInputs, optionalInputs));
            }
예제 #2
0
 private InputParameterSignature CreateSignature(InputParameterTypesKey callKey)
 {
     (MethodInfo? method, InputParameterPosition[]? positions)[] candidates = Methods