예제 #1
0
        /// <inheritdoc />
        /// <summary>
        ///     This section when called will read the data that is contained in
        ///     the list that was passed in from the constructor.
        /// </summary>
        public override void ReadSection()
        {
            // Iterate through the list of tagged data
            for (var currentIndex = StartIndex;
                 currentIndex < DataList.Length;
                 ++currentIndex)
            {
                // set the current data
                var currentData = DataList.GetPair(currentIndex);

                // Set the ending index of the file and break out of the loop
                if (currentData.GroupCode == GroupCodesBase.EndSectionMarker)
                {
                    EndIndex = currentIndex;
                    break;
                }

                // The master switch for the values
                switch (currentData.Value)
                {
                /*
                 * All Entities Cases will follow the same formula:
                 * 1. Create a new Buffer class
                 * 2. pass the Data list to the buffer class with the starting
                 *    index of the entity.
                 * 3. Add the entity to the entity list
                 */

                // LINE
                case LineGroupCodes.StartMarker:
                    var lineBuffer = new LineBuffer();
                    lineBuffer.Parse(DataList, currentIndex);
                    Entities.Add(new Line(lineBuffer));
                    continue;

                // LWPOLYLINE
                case LwPolylineCodes.StartMarker:
                    var lwPolyLineBuffer = new LwPolyLineBuffer();
                    lwPolyLineBuffer.Parse(DataList, currentIndex);
                    Entities.Add(new LwPolyLine(lwPolyLineBuffer));
                    continue;

                // HATCH
                case HatchCodes.StartMarker:
                    var hatchBuffer = new HatchBuffer();
                    hatchBuffer.Parse(DataList, currentIndex);
                    Entities.Add(new Hatch(hatchBuffer));
                    continue;

                // ARC
                case CircularArcCodes.ArcStartMarker:
                    var arcBuffer = new CircularArcBuffer();
                    arcBuffer.Parse(DataList, currentIndex);
                    Entities.Add(new CircularArc(arcBuffer));
                    continue;

                // TEXT
                case TextCodes.StartMarker:
                    var textBuffer = new TextBuffer();
                    textBuffer.Parse(DataList, currentIndex);
                    Entities.Add(new Text(textBuffer));
                    continue;

                // MTEXT
                case MTextCodes.StartMarker:
                    var mTextBuffer = new MTextBuffer();
                    mTextBuffer.Parse(DataList, currentIndex);
                    Entities.Add(new MText(mTextBuffer));
                    continue;

                // POINT
                case PointCodes.StartMarker:
                    var pointBuffer = new PointBuffer();
                    pointBuffer.Parse(DataList, currentIndex);
                    Entities.Add(new Point(pointBuffer));
                    continue;

                // CIRCLE
                case CircularArcCodes.CircleStartMarker:
                    var circleBuffer = new CircularArcBuffer();
                    circleBuffer.Parse(DataList, currentIndex);
                    Entities.Add(new Circle(circleBuffer));
                    break;

                // DEFAULT
                default:
                    continue;
                }
            }
        }