Example #1
0
        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);
        }
Example #2
0
        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;
        }