private void ProcessAnonymousType(TypeDefinition anonymousTypeDefinition, GenericInstanceType anonymousInstanceType,
            MethodDefinition constructorDefinition, ExpressionCollection constructorArguments)
        {
            for (int i = 0; i < constructorDefinition.Parameters.Count; i++)
            {
                ParameterDefinition currentParameter = constructorDefinition.Parameters[i];
                int genericParameterIndex = anonymousTypeDefinition.GenericParameters.IndexOf(currentParameter.ParameterType as GenericParameter);
                PropertyDefinition property = FindPropertyOfType(anonymousTypeDefinition, currentParameter.ParameterType);
				TypeReference propertyType = anonymousInstanceType.GenericArguments[genericParameterIndex];
				if (anonymousInstanceType.PostionToArgument.ContainsKey(genericParameterIndex))
				{
					propertyType = anonymousInstanceType.PostionToArgument[genericParameterIndex];
				}
                Expression parameterExpression =
                    new AnonymousPropertyInitializerExpression(property, propertyType);
                int argumentIndex = GetParameterIndexWithType(constructorDefinition, currentParameter.ParameterType);
                Expression argumentExpression = transformer.Visit(constructorArguments[argumentIndex].CloneExpressionOnly()) as Expression;
                initializerExpressions.Expressions.Add(
                    new BinaryExpression(BinaryOperator.Assign, parameterExpression, argumentExpression, this.typeSystem, null));
            }
        }
コード例 #2
0
        public override void VisitAnonymousPropertyInitializerExpression(AnonymousPropertyInitializerExpression node)
        {
            if (node.IsKey)
            {
                WriteKeyword(KeyWordWriter.Key);
                WriteSpace();
            }

            WriteToken(".");
			base.VisitAnonymousPropertyInitializerExpression(node);
        }
コード例 #3
0
		public override void VisitAnonymousPropertyInitializerExpression(AnonymousPropertyInitializerExpression node)
		{
			WritePropertyName(node.Property);
		}
コード例 #4
0
 public virtual void VisitAnonymousPropertyInitializerExpression(AnonymousPropertyInitializerExpression node)
 {
 }