Beispiel #1
0
        private void WriteRecordField(FtField field, int recordIndex)
        {
            OnFieldValueWriteReady(field, recordIndex);

            if (field.FixedWidth)
            {
                if (field.IsNull())
                {
                    writer.Write(field.Definition.FixedWidthNullValueText);
                }
                else
                {
                    string valueText = field.GetAsNonNullValueText();
                    string rawText   = EncodeFixedWidthValueText(valueText, field);
                    writer.Write(rawText);
                }
            }
            else
            {
                if (field.IsNull())
                {
                    writer.Write("");
                }
                else
                {
                    string valueText = field.GetAsNonNullValueText();

                    bool fieldQuoted;
                    switch (field.ValueQuotedType)
                    {
                    case FtQuotedType.Never:
                        fieldQuoted = false;
                        break;

                    case FtQuotedType.Always:
                        fieldQuoted = true;
                        break;

                    case FtQuotedType.Optional:
                        if (field.ValueAlwaysWriteOptionalQuote)
                        {
                            fieldQuoted = true;
                        }
                        else
                        {
                            fieldQuoted = DoesTextRequireQuotes(valueText, field.ValueWritePrefixSpace);
                        }
                        break;

                    default:
                        throw FtInternalException.Create(InternalError.SerializationWriter_WriteRecordField_UnsupportedQuotedType, field.HeadingQuotedType.ToString());
                    }

                    if (field.ValueWritePrefixSpace)
                    {
                        writer.Write(PrefixSpaceChar);
                    }

                    if (fieldQuoted)
                    {
                        writer.Write(QuoteChar);
                    }

                    string rawText = EncodeDelimitValueHeadingText(valueText, fieldQuoted);
                    writer.Write(rawText);

                    if (fieldQuoted)
                    {
                        writer.Write(QuoteChar);
                    }
                }
            }

            if (!field.Constant && !field.ValueAssigned)
            {
                // Field was not assigned a value (or null) so it will be null but any null sequence redirects will not have been processed yet. Do so now.
                Debug.Assert(field.IsNull());
                int fieldsAffectedFromIndex;
                field.CheckNullSequenceRedirect(out fieldsAffectedFromIndex);
            }
        }
Beispiel #2
0
 internal override bool CheckTriggered(FtField field)
 {
     return(field.IsNull());
 }