public bool Matches(MethodBase member)
        {
            Microsoft.Practices.Unity.Utility.Guard.ArgumentNotNull(member, "member");

            ParameterInfo[] parametersInfo = member.GetParameters();

            foreach (ParameterTypeMatchingInfo matchInfo in matches)
            {
                TypeMatchingRule typeRule =
                    new TypeMatchingRule(matchInfo.Match, matchInfo.IgnoreCase);
                foreach (ParameterInfo paramInfo in parametersInfo)
                {
                    if ((!paramInfo.IsOut && !paramInfo.IsReturn()) &&
                        (matchInfo.Kind == ParameterKind.Input ||
                         matchInfo.Kind == ParameterKind.InputOrOutput))
                    {
                        if (typeRule.Matches(paramInfo.ParameterType))
                        {
                            return(true);
                        }
                    }

                    if (paramInfo.IsOut &&
                        (matchInfo.Kind == ParameterKind.Output ||
                         matchInfo.Kind == ParameterKind.InputOrOutput))
                    {
                        if (typeRule.Matches(paramInfo.ParameterType.GetElementType()))
                        {
                            return(true);
                        }
                    }

                    if (paramInfo.IsReturn() && matchInfo.Kind == ParameterKind.ReturnValue)
                    {
                        if (typeRule.Matches(paramInfo.ParameterType))
                        {
                            return(true);
                        }
                    }
                }
                if (matchInfo.Kind == ParameterKind.ReturnValue)
                {
                    MethodInfo method = member as MethodInfo;
                    if (method != null)
                    {
                        if (typeRule.Matches(method.ReturnType))
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
        /// <summary>
        /// Check the given member to see if it has any matching parameters.
        /// </summary>
        /// <param name="member">Member to match.</param>
        /// <returns>true if member matches, false if it doesn't.</returns>
        public bool Matches(MethodBase member)
        {
            ParameterInfo[] parametersInfo = member.GetParameters();

            foreach (ParameterTypeMatchingInfo matchInfo in matches)
            {
                TypeMatchingRule typeRule =
                    new TypeMatchingRule(matchInfo.Match, matchInfo.IgnoreCase);
                foreach (ParameterInfo paramInfo in parametersInfo)
                {
                    if ((!paramInfo.IsOut && !paramInfo.IsRetval) &&
                        (matchInfo.Kind == ParameterKind.Input ||
                            matchInfo.Kind == ParameterKind.InputOrOutput))
                    {
                        if (typeRule.Matches(paramInfo.ParameterType))
                        {
                            return true;
                        }
                    }

                    if (paramInfo.IsOut &&
                        (matchInfo.Kind == ParameterKind.Output ||
                            matchInfo.Kind == ParameterKind.InputOrOutput))
                    {
                        if (typeRule.Matches(paramInfo.ParameterType.GetElementType()))
                        {
                            return true;
                        }
                    }

                    if (paramInfo.IsRetval && matchInfo.Kind == ParameterKind.ReturnValue)
                    {
                        if (typeRule.Matches(paramInfo.ParameterType))
                        {
                            return true;
                        }
                    }
                }
                if (matchInfo.Kind == ParameterKind.ReturnValue)
                {
                    MethodInfo method = member as MethodInfo;
                    if (method != null)
                    {
                        if (typeRule.Matches(method.ReturnType))
                        {
                            return true;
                        }
                    }
                }
            }
            return false;
        }
Exemple #3
0
        /// <summary>
        /// Check the given member to see if it has any matching parameters.
        /// </summary>
        /// <param name="member">Member to match.</param>
        /// <returns>true if member matches, false if it doesn't.</returns>
        public bool Matches(MethodBase member)
        {
            ParameterInfo[] parametersInfo = member.GetParameters();

            foreach (ParameterTypeMatchingInfo matchInfo in matches)
            {
                TypeMatchingRule typeRule =
                    new TypeMatchingRule(matchInfo.Match, matchInfo.IgnoreCase);
                foreach (ParameterInfo paramInfo in parametersInfo)
                {
                    if ((!paramInfo.IsOut && !paramInfo.IsRetval) &&
                        (matchInfo.Kind == ParameterKind.Input ||
                         matchInfo.Kind == ParameterKind.InputOrOutput))
                    {
                        if (typeRule.Matches(paramInfo.ParameterType))
                        {
                            return(true);
                        }
                    }

                    if (paramInfo.IsOut &&
                        (matchInfo.Kind == ParameterKind.Output ||
                         matchInfo.Kind == ParameterKind.InputOrOutput))
                    {
                        if (typeRule.Matches(paramInfo.ParameterType.GetElementType()))
                        {
                            return(true);
                        }
                    }

                    if (paramInfo.IsRetval && matchInfo.Kind == ParameterKind.ReturnValue)
                    {
                        if (typeRule.Matches(paramInfo.ParameterType))
                        {
                            return(true);
                        }
                    }
                }
                if (matchInfo.Kind == ParameterKind.ReturnValue)
                {
                    MethodInfo method = member as MethodInfo;
                    if (method != null)
                    {
                        if (typeRule.Matches(method.ReturnType))
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
        /// <summary>
        /// Check to see if the given member has a matching return type.
        /// </summary>
        /// <param name="member">Member to check.</param>
        /// <returns>true if return types match, false if they don't.</returns>
        public bool Matches(MethodBase member)
        {
            MethodInfo method = member as MethodInfo;

            if (method == null)
            {
                return(false);
            }

            return(typeMatchingRule.Matches(method.ReturnType));
        }
        public bool Matches(MethodBase member)
        {
            Microsoft.Practices.Unity.Utility.Guard.ArgumentNotNull(member, "member");

            ParameterInfo[] parametersInfo = member.GetParameters();

            foreach (ParameterTypeMatchingInfo matchInfo in matches)
            {
                TypeMatchingRule typeRule =
                    new TypeMatchingRule(matchInfo.Match, matchInfo.IgnoreCase);
                foreach (ParameterInfo paramInfo in parametersInfo)
                {
                    if ((!paramInfo.IsOut && !paramInfo.IsReturn()) &&
                        (matchInfo.Kind == ParameterKind.Input ||
                            matchInfo.Kind == ParameterKind.InputOrOutput))
                    {
                        if (typeRule.Matches(paramInfo.ParameterType))
                        {
                            return true;
                        }
                    }

                    if (paramInfo.IsOut &&
                        (matchInfo.Kind == ParameterKind.Output ||
                            matchInfo.Kind == ParameterKind.InputOrOutput))
                    {
                        if (typeRule.Matches(paramInfo.ParameterType.GetElementType()))
                        {
                            return true;
                        }
                    }

                    if (paramInfo.IsReturn() && matchInfo.Kind == ParameterKind.ReturnValue)
                    {
                        if (typeRule.Matches(paramInfo.ParameterType))
                        {
                            return true;
                        }
                    }
                }
                if (matchInfo.Kind == ParameterKind.ReturnValue)
                {
                    MethodInfo method = member as MethodInfo;
                    if (method != null)
                    {
                        if (typeRule.Matches(method.ReturnType))
                        {
                            return true;
                        }
                    }
                }
            }
            return false;
        }