/Rhino.Etl.Dsl/Macros/AccumulateMacro.cs

http://github.com/ayende/rhino-etl · C# · 39 lines · 23 code · 5 blank · 11 comment · 0 complexity · 5c03373922a09817e9f35c3d43979449 MD5 · raw file

  1. namespace Rhino.Etl.Dsl.Macros
  2. {
  3. using Boo.Lang.Compiler.Ast;
  4. using Core;
  5. using Rhino.Etl.Core.Operations;
  6. /// <summary>
  7. /// Generate the <see cref="AbstractAggregationOperation.Accumulate"/> method
  8. /// </summary>
  9. public class AccumulateMacro : AbstractChildMacro
  10. {
  11. /// <summary>
  12. /// Initializes a new instance of the <see cref="AccumulateMacro"/> class.
  13. /// </summary>
  14. public AccumulateMacro()
  15. : base("aggregate")
  16. {
  17. }
  18. /// <summary>
  19. /// Perform the actual expansion of the macro
  20. /// </summary>
  21. /// <param name="macro">The macro.</param>
  22. /// <returns></returns>
  23. protected override Statement DoExpand(MacroStatement macro)
  24. {
  25. Method accumulate = new Method("Accumulate");
  26. accumulate.Modifiers = TypeMemberModifiers.Override;
  27. accumulate.Parameters.Add(new ParameterDeclaration("row",CodeBuilder.CreateTypeReference(typeof(Row))));
  28. accumulate.Parameters.Add(new ParameterDeclaration("aggregate", CodeBuilder.CreateTypeReference(typeof(Row))));
  29. accumulate.Body = macro.Body;
  30. ParentMethods.Add(accumulate);
  31. return null;
  32. }
  33. }
  34. }