public override IEnumerable <Variable> FindVariables(IMethodVariables chain) { var parameters = Ctor.GetParameters(); for (var i = 0; i < parameters.Length; i++) { if (Parameters[i] == null) { var parameter = parameters[i]; Parameters[i] = chain.FindVariable(parameter.ParameterType); } } foreach (var parameter in Parameters) { yield return(parameter); } foreach (var setter in Setters) { setter.FindVariable(chain); } foreach (var setter in Setters) { yield return(setter.Variable); } if (ActivatorFrames.Any()) { var standin = new StandinMethodVariables(Variable, chain); foreach (var frame in ActivatorFrames) { foreach (var variable in frame.FindVariables(standin)) { yield return(variable); } } } }
public override void GenerateCode(GeneratedMethod method, ISourceWriter writer) { switch (Mode) { case ConstructorCallMode.Variable: writer.Write(Declaration() + ";"); ActivatorFrames.Write(method, writer); Next?.GenerateCode(method, writer); break; case ConstructorCallMode.ReturnValue: if (ActivatorFrames.Any()) { writer.Write(Declaration() + ";"); ActivatorFrames.Write(method, writer); writer.Write($"return {Variable.Usage};"); Next?.GenerateCode(method, writer); } else { writer.Write($"return {Invocation()};"); Next?.GenerateCode(method, writer); } break; case ConstructorCallMode.UsingNestedVariable: writer.UsingBlock(Declaration(), w => { ActivatorFrames.Write(method, writer); Next?.GenerateCode(method, w); }); break; } }