public Segment(int scope, int line, Segment parent) { Scope = scope; Line = line; Parent = parent; Children = new List<Segment>(); }
public Segment Begin(int line, int scope) { if (_root == null) { _root = new Segment(line, scope); _lastSegment = _root; return _lastSegment; } Segment segment = null; if (_lastSegment.Scope == scope) { segment = new Segment(line, scope, _lastSegment.Parent); segment.StartTiming(); _lastSegment.Parent.Children.Add(segment); } if (_lastSegment.Scope > scope) { var parent = _lastSegment.Parent; for (var i = 0; i < (_lastSegment.Scope - scope - 1); i++) { parent = parent.Parent; } segment = new Segment(line, scope, parent); segment.StartTiming(); parent.Children.Add(segment); } if (_lastSegment.Scope < scope) { segment = new Segment(line, scope, _lastSegment); segment.StartTiming(); _lastSegment.Children.Add(segment); } _lastSegment = segment; return segment; }
public void End(Segment segment) { segment.EndTiming(); }