コード例 #1
0
 public EdiPosition(EdiContainerType type)
 {
     Type        = type;
     HasIndex    = TypeHasIndex(type);
     Position    = -1;
     SegmentName = null;
 }
コード例 #2
0
ファイル: EdiPosition.cs プロジェクト: scottsparkman/EDI.Net
 public EdiPosition(EdiContainerType type)
 {
     Type                 = type;
     HasIndex             = TypeHasIndex(type);
     Position             = -1;
     FunctionalGroupCount = 0;
     MessageCount         = 0;
     SegmentCount         = 0;
     SegmentName          = null;
 }
コード例 #3
0
 public EdiPosition(EdiContainerType type, EdiPosition?parent = null)
 {
     Type              = type;
     HasIndex          = TypeHasIndex(type);
     Position          = -1;
     GroupCount        = parent?.GroupCount ?? 0;
     MessageCount      = parent?.MessageCount ?? 0;
     SegmentCount      = parent?.SegmentCount ?? 0;
     SegmentName       = parent?.SegmentName;
     SegmentCountCache = parent?.SegmentCount ?? 0;
 }
コード例 #4
0
ファイル: EdiWriter.cs プロジェクト: JelleHissink/EDI.Net
        private void WriteEnd(EdiContainerType type)
        {
            switch (type)
            {
            case EdiContainerType.Segment:
            case EdiContainerType.Element:
            case EdiContainerType.Component:
                InternalWriteEnd(type);
                break;

            default:
                throw EdiWriterException.Create(this, "Unexpected type when writing end: " + type, null);
            }
        }
コード例 #5
0
ファイル: EdiWriter.cs プロジェクト: JelleHissink/EDI.Net
        private void AutoCompleteClose(EdiContainerType type)
        {
            // write closing symbol and calculate new state
            while (Peek() >= type && Top > 0)
            {
                EdiToken token;
                bool     forcebreak = false;
                if (Peek() == type && _currentPosition.HasIndex)
                {
                    token      = GetCloseTokenForType(type);
                    forcebreak = true;
                }
                else
                {
                    token = GetCloseTokenForType(Pop());
                }

                WriteEnd(token);

                EdiContainerType currentLevelType = Peek();
                switch (currentLevelType)
                {
                case EdiContainerType.Segment:
                    _currentState = State.Segment;
                    break;

                case EdiContainerType.Element:
                    _currentState = State.Element;
                    break;

                case EdiContainerType.Component:
                    _currentState = State.Component;
                    break;

                case EdiContainerType.None:
                    _currentState = State.Start;
                    break;

                default:
                    throw EdiWriterException.Create(this, "Unknown EdiContainerType: " + currentLevelType, null);
                }
                if (forcebreak)
                {
                    break;
                }
            }
        }
コード例 #6
0
ファイル: EdiReader.cs プロジェクト: scottsparkman/EDI.Net
        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));
                }
            }
        }
コード例 #7
0
ファイル: EdiWriter.cs プロジェクト: JelleHissink/EDI.Net
        private EdiToken GetCloseTokenForType(EdiContainerType type)
        {
            switch (type)
            {
            case EdiContainerType.Segment:
                return(EdiToken.SegmentStart);

            case EdiContainerType.Element:
                return(EdiToken.None);

            case EdiContainerType.Component:
                return(EdiToken.None);

            case EdiContainerType.None:
                return(EdiToken.None);

            default:
                throw EdiWriterException.Create(this, "No close token for type: " + type, null);
            }
        }
コード例 #8
0
ファイル: EdiWriter.cs プロジェクト: JelleHissink/EDI.Net
 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;
     }
 }
コード例 #9
0
ファイル: EdiWriter.cs プロジェクト: JelleHissink/EDI.Net
 internal void InternalWriteEnd(EdiContainerType container)
 {
     AutoCompleteClose(container);
 }
コード例 #10
0
ファイル: EdiWriter.cs プロジェクト: indice-co/EDI.Net
        private void AutoCompleteClose(EdiContainerType type) {
            // write closing symbol and calculate new state
            while (Peek() >= type && Top > 0) {

                EdiToken token;
                bool forcebreak = false;
                if (Peek() == type && _currentPosition.HasIndex) {
                    token = GetCloseTokenForType(type);
                    forcebreak = true;
                } else {
                    token = GetCloseTokenForType(Pop());
                }

                WriteEnd(token);

                EdiContainerType currentLevelType = Peek();
                switch (currentLevelType) {
                    case EdiContainerType.Segment:
                        _currentState = State.Segment;
                        break;
                    case EdiContainerType.Element:
                        _currentState = State.Element;
                        break;
                    case EdiContainerType.Component:
                        _currentState = State.Component;
                        break;
                    case EdiContainerType.None:
                        _currentState = State.Start;
                        break;
                    default:
                        throw EdiWriterException.Create(this, "Unknown EdiContainerType: " + currentLevelType, null);
                }
                if (forcebreak)
                    break;
            }
        }
コード例 #11
0
ファイル: EdiWriter.cs プロジェクト: indice-co/EDI.Net
 private EdiToken GetCloseTokenForType(EdiContainerType type) {
     switch (type) {
         case EdiContainerType.Segment:
             return EdiToken.SegmentStart;
         case EdiContainerType.Element:
             return EdiToken.None;
         case EdiContainerType.Component:
             return EdiToken.None;
         case EdiContainerType.None:
             return EdiToken.None;
         default:
             throw EdiWriterException.Create(this, "No close token for type: " + type, null);
     }
 }
コード例 #12
0
ファイル: EdiWriter.cs プロジェクト: indice-co/EDI.Net
 private void WriteEnd(EdiContainerType type) {
     switch (type) {
         case EdiContainerType.Segment:
         case EdiContainerType.Element:
         case EdiContainerType.Component:
             InternalWriteEnd(type);
             break;
         default:
             throw EdiWriterException.Create(this, "Unexpected type when writing end: " + type, null);
     }
 }
コード例 #13
0
ファイル: EdiWriter.cs プロジェクト: indice-co/EDI.Net
 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;
 }
コード例 #14
0
ファイル: EdiWriter.cs プロジェクト: indice-co/EDI.Net
 internal void InternalWriteStart(EdiToken token, EdiContainerType container) {
     AutoComplete(token);
     Push(container);
 }
コード例 #15
0
ファイル: EdiPosition.cs プロジェクト: indice-co/EDI.Net
 internal static bool TypeHasIndex(EdiContainerType type) {
     return (type == EdiContainerType.Segment || type == EdiContainerType.Element || type == EdiContainerType.Component);
 }
コード例 #16
0
ファイル: EdiPosition.cs プロジェクト: scottsparkman/EDI.Net
 internal static bool TypeHasIndex(EdiContainerType type)
 {
     return(type == EdiContainerType.Segment || type == EdiContainerType.Element || type == EdiContainerType.Component);
 }
コード例 #17
0
ファイル: EdiReader.cs プロジェクト: indice-co/EDI.Net
        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));
                }
            }
        }
コード例 #18
0
ファイル: EdiWriter.cs プロジェクト: JelleHissink/EDI.Net
 internal void InternalWriteStart(EdiToken token, EdiContainerType container)
 {
     AutoComplete(token);
     Push(container);
 }
コード例 #19
0
ファイル: EdiWriter.cs プロジェクト: indice-co/EDI.Net
 internal void InternalWriteEnd(EdiContainerType container) {
     AutoCompleteClose(container);
 }
コード例 #20
0
ファイル: EdiPosition.cs プロジェクト: indice-co/EDI.Net
 public EdiPosition(EdiContainerType type) {
     Type = type;
     HasIndex = TypeHasIndex(type);
     Position = -1;
     SegmentName = null;
 }