예제 #1
0
        internal void LoadFieldHeading(int headingLineIndex)
        {
            string headingText = FinishText();

            field.LoadPosition(position, fieldLength, rawOffset, rawLength);
            field.LoadHeading(headingLineIndex, headingText);
        }
예제 #2
0
        internal void Finish()
        {
            switch (state)
            {
            case State.Out:
                // nothing to do
                break;

            case State.InOutField:
                state = State.Out;
                break;

            case State.InFixedWidthField:
                if (!core.Seeking)
                {
                    LoadFixedWidthHeadingValue();
                }
                ExitActiveField();
                state = State.Out;
                break;

            case State.InDelimitedField:
                if (!core.Seeking)
                {
                    LoadDelimitedHeadingValue();
                }
                ExitActiveField();
                state = State.Out;
                break;

            case State.OutIgnoreChars:
                state = State.Out;
                break;

            default:
                throw FtInternalException.Create(InternalError.HeadingLineRecordParser_Finish_UnsupportedState, state.ToString());
            }

            if (fieldCount < core.FieldList.Count)
            {
                if (!core.AllowIncompleteRecords)
                {
                    FtSerializationError error = headingLines ? FtSerializationError.HeadingLineNotEnoughFields : FtSerializationError.RecordNotEnoughFields;
                    string formatString        = headingLines ? Properties.Resources.HeadingLineRecordParser_Finish_HeadingLineNotEnoughFields : Properties.Resources.HeadingLineRecordParser_Finish_RecordNotEnoughFields;
                    throw new FtSerializationException(error, string.Format(formatString, fieldCount, core.FieldList.Count));
                }
                else
                {
                    for (int i = fieldCount; i < core.FieldList.Count; i++)
                    {
                        activeField.LoadPosition(-1, -1, -1, -1);
                        if (headingLines)
                        {
                            activeField.LoadHeading(index, "");
                        }
                        else
                        {
                            activeField.LoadNullValue();
                        }
                    }
                }
            }
        }