Ejemplo n.º 1
0
        private bool ExtendsTheCallerType(IMethodElement method, ITypeElement callerType, Expression qualifier)
        {
            if (method == null || callerType == null)
            {
                return(false);
            }


            if (method.Parameters.Count == 0)
            {
                return(false);
            }
            ISourceTreeResolver  resolver  = ParserServices.SourceTreeResolver;
            ExpressionCollection arguments = new ExpressionCollection();

            arguments.Add(qualifier);
            method = GenericElementActivator.ActivateMemberIfNeeded(resolver, method, arguments, null, ArgumentsHelper.ResolveArgumentTypes(resolver, arguments)) as IMethodElement;

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

            IParameterElement extensionParam = method.Parameters[0] as IParameterElement;

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


            ITypeReferenceExpression typeRef = extensionParam.Type;

            if (typeRef == null)
            {
                return(false);
            }
            ITypeElement type = typeRef.GetDeclaration() as ITypeElement;

            if (type == null)
            {
                return(false);
            }
            IArrayTypeElement arrayType = callerType as IArrayTypeElement;

            //if (arrayType != null)
            //{
            //  return true;
            //}
            //else
            return(ArgumentsHelper.HasParamConversion(resolver, extensionParam, callerType, qualifier, TypeConversionMode.ImplicitConversion));
        }