private string GetCurrentPath() { if (_currentPosition.Type == EdiContainerType.None) { return(string.Empty); } bool startingSegment = _currentState != State.SegmentStart; IEnumerable <EdiPosition> positions = (!startingSegment) ? _stack : _stack.Concat(new[] { _currentPosition }); return(EdiPosition.BuildPath(positions)); }
private EdiContainerType Pop() { EdiPosition oldPosition = _currentPosition; if (_stack != null && _stack.Count > 0) { _currentPosition = _stack[_stack.Count - 1]; _stack.RemoveAt(_stack.Count - 1); } else { _currentPosition = new EdiPosition(); } return(oldPosition.Type); }
private void Push(EdiContainerType value) { if (_currentPosition.Type == EdiContainerType.None) { _currentPosition = new EdiPosition(value); } else { _stack.Add(_currentPosition); _currentPosition = new EdiPosition(value); // this is a little hacky because Depth increases when first property/value is written but only testing here is faster/simpler if (_maxDepth != null && Depth + 1 > _maxDepth && !_hasExceededMaxDepth) { _hasExceededMaxDepth = true; throw EdiReaderException.Create(this, "The reader's MaxDepth of {0} has been exceeded.".FormatWith(CultureInfo.InvariantCulture, _maxDepth)); } } }
internal static EdiReaderException Create(IEdiLineInfo lineInfo, string path, string message, Exception ex) { message = EdiPosition.FormatMessage(lineInfo, path, message); int lineNumber; int linePosition; if (lineInfo != null && lineInfo.HasLineInfo()) { lineNumber = lineInfo.LineNumber; linePosition = lineInfo.LinePosition; } else { lineNumber = 0; linePosition = 0; } return(new EdiReaderException(message, ex, path, lineNumber, linePosition)); }
private EdiContainerType Pop() { EdiPosition oldPosition; if (_stack.Count > 0) { oldPosition = _currentPosition; _currentPosition = _stack[_stack.Count - 1]; _stack.RemoveAt(_stack.Count - 1); } else { oldPosition = _currentPosition; _currentPosition = new EdiPosition(); } if (_maxDepth != null && Depth <= _maxDepth) { _hasExceededMaxDepth = false; } return(oldPosition.Type); }
private void Push(EdiContainerType value) { if (_currentPosition.Type != EdiContainerType.None) { if (_stack == null) { _stack = new List <EdiPosition>(); } if (_currentPosition.Type == value && _currentPosition.HasIndex) { _currentPosition.Position++; return; } else { _stack.Add(_currentPosition); } } _currentPosition = new EdiPosition(value); if (_currentPosition.HasIndex) { _currentPosition.Position = 0; } }
/// <summary> /// Create the specified lineInfo, path and message. /// </summary> /// <param name="lineInfo">Line info.</param> /// <param name="path">Path.</param> /// <param name="message">Message.</param> internal static EdiException Create(IEdiLineInfo lineInfo, string path, string message) { message = EdiPosition.FormatMessage(lineInfo, path, message); return(new EdiException(message)); }
private EdiContainerType Pop() { EdiPosition oldPosition = _currentPosition; if (_stack != null && _stack.Count > 0) { _currentPosition = _stack[_stack.Count - 1]; _stack.RemoveAt(_stack.Count - 1); } else { _currentPosition = new EdiPosition(); } return oldPosition.Type; }
private void Push(EdiContainerType value) { if (_currentPosition.Type != EdiContainerType.None) { if (_stack == null) { _stack = new List<EdiPosition>(); } if (_currentPosition.Type == value && _currentPosition.HasIndex) { _currentPosition.Position++; return; } else { _stack.Add(_currentPosition); } } _currentPosition = new EdiPosition(value); if (_currentPosition.HasIndex) _currentPosition.Position = 0; }
/// <summary> /// Create the specified path, message and ex. /// </summary> /// <param name="path">Path.</param> /// <param name="message">Message.</param> /// <param name="ex">Ex.</param> internal static EdiWriterException Create(string path, string message, Exception ex) { message = EdiPosition.FormatMessage(null, path, message); return(new EdiWriterException(message, ex, path)); }
private EdiContainerType Pop() { EdiPosition oldPosition; if (_stack.Count > 0) { oldPosition = _currentPosition; _currentPosition = _stack[_stack.Count - 1]; _stack.RemoveAt(_stack.Count - 1); } else { oldPosition = _currentPosition; _currentPosition = new EdiPosition(); } if (_maxDepth != null && Depth <= _maxDepth) _hasExceededMaxDepth = false; return oldPosition.Type; }