Ejemplo n.º 1
0
        /// <summary>
        /// Detects if list of parameters matches the method signature
        /// </summary>
        /// <param name="parameterList">Array of parameters for the method</param>
        /// <returns>True if the method signature matches the parameterList, otherwise False</returns>
        public bool HasParameterSignature(object[] parameterList)
        {
            if (parameterList == null)
            {
                throw new ArgumentNullException(nameof(parameterList));
            }
            if (parameterList.Count() > this.parameterInfoList.Count())
            {
                return(false);
            }

            for (int i = 0; i < this.parameterInfoList.Count(); i++)
            {
                ParameterInfo parameterInfo = this.parameterInfoList[i];
                if (parameterList.Count() <= i)
                {
                    if (!parameterInfo.IsOptional)
                    {
                        return(false);
                    }
                }
                else
                {
                    object parameter = parameterList[i];
                    bool   isMatch   = RpcMethod.ParameterMatches(parameterInfo, parameter);
                    if (!isMatch)
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Detects if list of parameters matches the method signature
        /// </summary>
        /// <param name="parameterList">Array of parameters for the method</param>
        /// <returns>True if the method signature matches the parameterList, otherwise False</returns>
        public bool HasParameterSignature(object[] parameterList, out object[] correctedParameterList)
        {
            if (parameterList == null)
            {
                throw new ArgumentNullException(nameof(parameterList));
            }

            correctedParameterList = parameterList;
            if (parameterList.Count() > this.parameterInfoList.Count())
            {
                return(false);
            }

            for (int i = 0; i < this.parameterInfoList.Count(); i++)
            {
                ParameterInfo parameterInfo = this.parameterInfoList[i];
                if (parameterList.Count() <= i)
                {
                    if (!parameterInfo.IsOptional)
                    {
                        return(false);
                    }
                    correctedParameterList = new object[correctedParameterList.Length + 1];
                    correctedParameterList[correctedParameterList.Length - 1] = Type.Missing;
                }
                else
                {
                    object parameter = parameterList[i];
                    bool   isMatch   = RpcMethod.ParameterMatches(parameterInfo, parameter);
                    if (!isMatch)
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }