Los rows son... Oh wait, English. The way I am using it is that I have a set of rows that contains multiple "types" - I branch based on those types and the output from both of those branches is a lesser amount of rows but I still want to do something with them. With the original branchingoperation it specifically eats all the output rows. This one just passes them through so they can be used after that if needed.
On Dec 25, 12:01 am, "Ayende Rahien" <[email protected]> wrote: > Can you explain, in English, what it is suppose to do? > > > > On Wed, Dec 24, 2008 at 12:06 AM, webpaul <[email protected]> wrote: > > > I created a BranchAndReturnOperation which allows me to do this: > > > new BranchAndReturnOperation(this) > > .AddBranch( > > new FilterRowsOnType(this, "type1") > > new DoSomeStuff1AndReturnRows(this) > > ) > > .AddBranch( > > new FilterRowsOnType(this, "type2"), > > new DoSomeStuff2AndReturnRows(this) > > ), > > > And then use the result rows from both of those branches. Just putting > > the idea here in case anyone wants it, the code below will need a > > little bit of cleanup before it could go in the etl trunk. But I'm > > more curious if anyone sees a reason why this wasn't done in the first > > place. I also changed the syntax a bit because I didn't like the > > partial.register stuff. If you didn't want one of the branches to > > return rows you could just make a null operation which ate the rows. > > > public class BranchAndReturnOperation : BaseOperation > > { > > private readonly List<IOperation> operations = new > > List<IOperation> > > (); > > > public BranchAndReturnOperation(BaseProcess Process) : base > > (Process) { } > > > /// <summary> > > /// Adds the specified operation to this branching operation > > /// </summary> > > /// <param name="operation">The operation.</param> > > /// <returns></returns> > > public BranchAndReturnOperation Add(IOperation operation) > > { > > operations.Add(operation); > > return this; > > } > > > public BranchAndReturnOperation AddBranch(params IOperation[] > > branchOperations) > > { > > PartialProcessOperation subProcess = new > > PartialProcessOperation(); > > > foreach (IOperation operation in branchOperations) > > subProcess.Register(operation); > > > operations.Add(subProcess); > > > return this; > > } > > > /// <summary> > > /// Initializes this instance > > /// </summary> > > /// <param name="pipelineExecuter">The current pipeline > > executer.</ > > param> > > public override void PrepareForExecution(IPipelineExecuter > > pipelineExecuter) > > { > > base.PrepareForExecution(pipelineExecuter); > > foreach (IOperation operation in operations) > > { > > > operation.PrepareForExecution(pipelineExecuter); > > } > > } > > > /// <summary> > > /// Executes this operation, sending the input of this > > operation > > /// to all its child operations > > /// </summary> > > /// <param name="rows">The rows.</param> > > /// <returns></returns> > > public override IEnumerable<Row> Execute(IEnumerable<Row> > > rows) > > { > > List<Row> copiedRows = new List<Row>(rows); > > foreach (IOperation operation in operations) > > { > > List<Row> cloned = > > copiedRows.ConvertAll<Row>(delegate(Row row) > > { > > return row.Clone(); > > }); > > > IEnumerable<Row> enumerable = operation.Execute > > (cloned); > > foreach (Row row in enumerable) > > yield return row; > > } > > } > > } > > }- Hide quoted text - > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Rhino Tools Dev" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rhino-tools-dev?hl=en -~----------~----~----~----~------~----~------~--~---
