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)); } }
public override void VisitAnonymousPropertyInitializerExpression(AnonymousPropertyInitializerExpression node) { if (node.IsKey) { WriteKeyword(KeyWordWriter.Key); WriteSpace(); } WriteToken("."); base.VisitAnonymousPropertyInitializerExpression(node); }
public override void VisitAnonymousPropertyInitializerExpression(AnonymousPropertyInitializerExpression node) { WritePropertyName(node.Property); }
public virtual void VisitAnonymousPropertyInitializerExpression(AnonymousPropertyInitializerExpression node) { }