示例#1
0
        private void BuildTypedArguments(Expression expression)
        {
            AstNodeCollection <AstType> typedArguments = null;

            var identifierExpression = expression as IdentifierExpression;

            if (identifierExpression != null)
            {
                typedArguments = identifierExpression.TypeArguments;
            }
            else
            {
                var memberRefExpression = expression as MemberReferenceExpression;
                if (memberRefExpression != null)
                {
                    typedArguments = memberRefExpression.TypeArguments;
                }
            }

            var method = this.ResolveResult.Member as IMethod;

            if (method != null)
            {
                this.TypeArguments = new TypeParamExpression[method.TypeParameters.Count];

                if (typedArguments != null && typedArguments.Count == method.TypeParameters.Count)
                {
                    var list = typedArguments.ToList();
                    for (int i = 0; i < list.Count; i++)
                    {
                        this.TypeArguments[i] = new TypeParamExpression(method.TypeParameters[i].Name, list[i], null);
                    }
                }
                else
                {
                    for (int i = 0; i < method.TypeArguments.Count; i++)
                    {
                        this.TypeArguments[i] = new TypeParamExpression(method.TypeParameters[i].Name, null, method.TypeArguments[i]);
                    }
                }

                if (method.DeclaringType != null && method.DeclaringTypeDefinition != null && method.DeclaringTypeDefinition.TypeParameters.Count > 0)
                {
                    var typeParams = method.DeclaringTypeDefinition.TypeParameters;
                    var typeArgs   = method.DeclaringType.TypeArguments;
                    var temp       = new TypeParamExpression[typeParams.Count];

                    for (int i = 0; i < typeParams.Count; i++)
                    {
                        temp[i] = new TypeParamExpression(typeParams[i].Name, null, typeArgs[i], true);
                    }

                    this.TypeArguments = this.TypeArguments.Concat(temp).ToArray();
                }
            }
        }
示例#2
0
        private void BuildTypedArguments(MemberResolveResult rr)
        {
            var typeParams = rr.Member.DeclaringTypeDefinition.TypeParameters;
            var typeArgs   = rr.Member.DeclaringType.TypeArguments;
            var temp       = new TypeParamExpression[typeParams.Count];

            for (int i = 0; i < typeParams.Count; i++)
            {
                temp[i] = new TypeParamExpression(typeParams[i].Name, null, typeArgs[i], true);
            }

            this.TypeArguments = temp;
        }
示例#3
0
        private void BuildTypedArguments(Expression expression)
        {
            AstNodeCollection<AstType> typedArguments = null;

            var identifierExpression = expression as IdentifierExpression;
            if (identifierExpression != null)
            {
                typedArguments = identifierExpression.TypeArguments;
            }
            else
            {
                var memberRefExpression = expression as MemberReferenceExpression;
                if (memberRefExpression != null)
                {
                    typedArguments = memberRefExpression.TypeArguments;
                }
            }

            var method = this.ResolveResult.Member as IMethod;

            if (method != null)
            {
                this.TypeArguments = new TypeParamExpression[method.TypeParameters.Count];

                if (typedArguments != null && typedArguments.Count == method.TypeParameters.Count)
                {
                    var list = typedArguments.ToList();
                    for (int i = 0; i < list.Count; i++)
                    {
                        this.TypeArguments[i] = new TypeParamExpression(method.TypeParameters[i].Name, list[i], null);
                    }
                }
                else
                {
                    for (int i = 0; i < method.TypeArguments.Count; i++)
                    {
                        this.TypeArguments[i] = new TypeParamExpression(method.TypeParameters[i].Name, null, method.TypeArguments[i]);
                    }
                }

                if (method.DeclaringType != null && method.DeclaringTypeDefinition != null && method.DeclaringTypeDefinition.TypeParameters.Count > 0)
                {
                    var typeParams = method.DeclaringTypeDefinition.TypeParameters;
                    var typeArgs = method.DeclaringType.TypeArguments;
                    var temp = new TypeParamExpression[typeParams.Count];

                    for (int i = 0; i < typeParams.Count; i++)
                    {
                        temp[i] = new TypeParamExpression(typeParams[i].Name, null, typeArgs[i], true);
                    }

                    this.TypeArguments = this.TypeArguments.Concat(temp).ToArray();
                }
            }
        }
示例#4
0
        private void BuildTypedArguments(MemberResolveResult rr)
        {
            var typeParams = rr.Member.DeclaringTypeDefinition.TypeParameters;
            var typeArgs = rr.Member.DeclaringType.TypeArguments;
            var temp = new TypeParamExpression[typeParams.Count];

            for (int i = 0; i < typeParams.Count; i++)
            {
                temp[i] = new TypeParamExpression(typeParams[i].Name, null, typeArgs[i], true);
            }

            this.TypeArguments = temp;
        }