/// <summary>
        /// Construct a new <see cref="ReturnTypeMatchingRule"/> that matches
        /// members with the given return type.
        /// </summary>
        /// <param name="returnType">Type to look for.</param>
        public ReturnTypeMatchingRule(Type returnType)
        {
            if (returnType == null)
                throw new ArgumentNullException(nameof(returnType));

            typeMatchingRule = new TypeMatchingRule(returnType.FullName);
        }
 /// <summary>
 /// Construct a new <see cref="ReturnTypeMatchingRule"/> that matches
 /// members with the given return type.
 /// </summary>
 /// <param name="returnType">Type to look for.</param>
 public ReturnTypeMatchingRule(Type returnType)
 {
     if (returnType == null)
     {
         throw new ArgumentNullException("returnType");
     }
     typeMatchingRule = new TypeMatchingRule(returnType.FullName);
 }
示例#3
0
 /// <summary>
 /// Construct a new <see cref="ReturnTypeMatchingRule"/> that matches
 /// members with the given return type.
 /// </summary>
 /// <param name="returnType">Type to look for.</param>
 public ReturnTypeMatchingRule(Type returnType)
 {
     if (returnType == null)
     {
         throw new ArgumentNullException("returnType");
     }
     typeMatchingRule = new TypeMatchingRule(returnType.FullName);
 }
        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);
        }
示例#5
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 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;
        }
        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>
 /// Construct a new <see cref="ReturnTypeMatchingRule"/> that matches
 /// the given return type by name.
 /// </summary>
 /// <remarks>See the <see cref="TypeMatchingRule"/> class for details on how
 /// type name matches are done.</remarks>
 /// <param name="returnTypeName">Type name to match.</param>
 /// <param name="ignoreCase">If false, name comparison is case sensitive. If true, comparison
 /// is case insensitive.</param>
 public ReturnTypeMatchingRule(string returnTypeName, bool ignoreCase)
 {
     typeMatchingRule = new TypeMatchingRule(returnTypeName, ignoreCase);
 }
 /// <summary>
 /// Construct a new <see cref="ReturnTypeMatchingRule"/> that matches
 /// the given return type by name.
 /// </summary>
 /// <remarks>See the <see cref="TypeMatchingRule"/> class for details on how
 /// type name matches are done.</remarks>
 /// <param name="returnTypeName">Type name to match. Name comparisons are case sensitive.</param>
 public ReturnTypeMatchingRule(string returnTypeName)
 {
     typeMatchingRule = new TypeMatchingRule(returnTypeName);
 }
示例#10
0
 /// <summary>
 /// Construct a new <see cref="ReturnTypeMatchingRule"/> that matches
 /// the given return type by name.
 /// </summary>
 /// <remarks>See the <see cref="TypeMatchingRule"/> class for details on how
 /// type name matches are done.</remarks>
 /// <param name="returnTypeName">Type name to match.</param>
 /// <param name="ignoreCase">If false, name comparison is case sensitive. If true, comparison
 /// is case insensitive.</param>
 public ReturnTypeMatchingRule(string returnTypeName, bool ignoreCase)
 {
     typeMatchingRule = new TypeMatchingRule(returnTypeName, ignoreCase);
 }
示例#11
0
 /// <summary>
 /// Construct a new <see cref="ReturnTypeMatchingRule"/> that matches
 /// the given return type by name.
 /// </summary>
 /// <remarks>See the <see cref="TypeMatchingRule"/> class for details on how
 /// type name matches are done.</remarks>
 /// <param name="returnTypeName">Type name to match. Name comparisons are case sensitive.</param>
 public ReturnTypeMatchingRule(string returnTypeName)
 {
     typeMatchingRule = new TypeMatchingRule(returnTypeName);
 }