BoilerPlate.Program.mkDo C# (CSharp) Method

mkDo() static private method

static private mkDo ( int i, bool isVoid ) : string
i int
isVoid bool
return string
        static string mkDo(int i, bool isVoid)
        {
            string typeArgs;
              string contType;
              string chordType;
              string retType;
              string invocation;

              if (isVoid) {
            typeArgs = mkParams(i);
            contType = "Action";
            chordType = "ActionChord<" + mkArgCount(i) + ", " + mkTuple(i) + ">";
            retType = "Unit";
            invocation = "continuation(" + mkProjections("", i, "a") + "); return Unit.Null;";

              } else {
            typeArgs = mkNVParams(i);
            contType = "Func";
            chordType = "FuncChord<" + mkArgCount(i) + ", " + mkTuple(i) + ",R>";
            retType = "R";
            invocation = "return continuation(" + mkProjections("", i, "a") + ");";
              }

              return String.Format(
            @"
               /// <summary>
               /// Completes this join pattern with body <paramref name=""continuation""/> and registers it with the current <c>Join</c> instance.
               /// </summary>
               /// <param name=""chord""> the join pattern to complete.</param>
               /// <param name=""continuation""> the code to execute when the join pattern is enabled.</param>
               /// <exception cref=""JoinException""> thrown if <paramref name=""continuation""/> is null, the pattern repeats a
               /// channel, a channel is foreign to this pattern's join instance, or the join pattern is empty.
               /// </exception>
               public static void Do{0}(this {2} chord, {1}{0} continuation) {{
              if (continuation == null) JoinException.NullContinuationException();
              var copy =
            new Chord<{4},{3}>(
            chord.mJoin, chord.mPattern, continuation,
            delegate ({4} a) {{ {5} }}
              );
              chord.mJoin.Register(copy);
               }}
            ",
              typeArgs, contType, chordType ,retType, mkTuple(i), invocation);
        }