private void MigrateMessage(ThreadSafeStack <ITransaction> stack, ITransaction source, ITransaction target, int level) { // Note that stack.ToArray() gives an array reversed, which is the opposite of Java. ITransaction[] onStackTransactions = stack.ToArray(); ITransaction current = (level < stack.Count ? onStackTransactions[stack.Count - 1 - level] : null); bool shouldKeep = false; foreach (IMessage child in source.Children) { if (child != current) { target.AddChild(child); } else { DefaultTransaction cloned = new DefaultTransaction(current.Type, current.Name, _mManager); cloned.Timestamp = current.Timestamp; cloned.DurationInMicros = current.DurationInMicros; cloned.AddData(current.Data); cloned.Status = CatConstants.SUCCESS; target.AddChild(cloned); MigrateMessage(stack, current, cloned, level + 1); shouldKeep = true; } } lock (source.Children) { source.Children.Clear(); } if (shouldKeep) { source.AddChild(current); } }
public T[] ToArray() { return(_wrapped.ToArray()); }