void PropagateReferences(MethodInvocationExpression enumerableConstructorInvocation,
MethodInvocationExpression enumeratorConstructorInvocation)
{
// propagate the necessary parameters from
// the enumerable to the enumerator
foreach (ParameterDeclaration parameter in _generator.Method.Parameters)
{
InternalParameter entity = (InternalParameter)parameter.Entity;
if (entity.IsUsed)
{
enumerableConstructorInvocation.Arguments.Add(
CodeBuilder.CreateReference(parameter));
PropagateFromEnumerableToEnumerator(enumeratorConstructorInvocation,
entity.Name,
entity.Type);
}
}
// propagate the external self reference if necessary
if (null != _externalEnumeratorSelf)
{
IType type = (IType)_externalEnumeratorSelf.Type.Entity;
enumerableConstructorInvocation.Arguments.Add(CodeBuilder.CreateSelfReference(type));
PropagateFromEnumerableToEnumerator(enumeratorConstructorInvocation,
"self_",
type);
}
}