Esempio n. 1
0
        /// <summary>
        /// Finds all occurences of <c>genericParameter</c> in <c>openType</c> and the corresponding concrete types in <c>closedType</c>.
        /// Returns true iff all occurences of the generic parameter in the open type correspond to the same concrete type in the closed type
        /// and this type satisfies given <c>constraints</c>. Returns the concrete type in <c>match</c> if so.
        /// </summary>
        private static bool MatchGenericParameter(Type genericParameter, Type closedType, Type openType, Dictionary <Type, Type> binding, ref Type match)
        {
            Type m = match;

            bool result = ReflectionUtils.BindGenericParameters(openType, closedType, (parameter, type) => {
                if (parameter == genericParameter)
                {
                    if (m != null)
                    {
                        return(m == type);
                    }

                    if (ConstraintsViolated(type, genericParameter, binding))
                    {
                        return(false);
                    }

                    m = type;
                }

                return(true);
            });

            match = m;
            return(result);
        }