private AphidInteropMethodArg( ParameterInfo parameter, object argument, bool?constructsParamArray = null) { Argument = argument; if (argument != null) { ArgumentType = argument.GetType(); lock (ParamCache) { if (!ParamCache.TryGetValue(parameter, out _paramInfo)) { ParamCache.Add( parameter, _paramInfo = new ParameterInfoCache(parameter, ArgumentType)); _argInfo = _paramInfo.InitialArgumentTypeCache; } else if (!_paramInfo.ArgumentTypeCache.TryGetValue(ArgumentType, out _argInfo)) { _paramInfo.ArgumentTypeCache.Add( ArgumentType, _argInfo = new ArgumentTypeCache( ArgumentType, _paramInfo, _paramInfo.TargetType)); } } } else { lock (ParamCache) { if (!ParamCache.TryGetValue(parameter, out _paramInfo)) { ParamCache.Add( parameter, _paramInfo = new ParameterInfoCache(parameter)); } _argInfo = new ArgumentTypeCache(); } } IsGeneric = TargetType.IsGenericType; if (_argInfo.NeedsStringToCharCheck) { if (((string)Argument).Length == 1) { IsExactBasicTypeMatch = true; } //IsExactUserReferenceTypeMatch = false; } else if (_argInfo.NeedsDecimalFitCheck) { IsConvertibleNumberPair = AphidTypeConverter.CanConvertDecimal( (decimal)Argument, TargetType); } else { IsConvertibleNumberPair = _argInfo.IsConvertibleNumberPair; IsExactBasicTypeMatch = _argInfo.IsExactBasicTypeMatch; IsExactUserReferenceTypeMatch = _argInfo.IsExactUserReferenceTypeMatch; } if (HasParamArray) { if (constructsParamArray == null) { if (!HasParamArray) { ConstructsParamArray = false; PassesParamArray = false; } else { if (!IsExactTypeMatch && ArgumentType?.GetInterface("IEnumerable") != null) { ConstructsParamArray = true; PassesParamArray = false; } else { ConstructsParamArray = false; PassesParamArray = true; } } } else { ConstructsParamArray = constructsParamArray.Value; PassesParamArray = !ConstructsParamArray; } } }