private string PadFixedWidthText(string text, FtFieldDefinition definition, FtPadAlignment padAlignment, FtPadCharType padCharType, char padChar, char endOfValueChar) { bool leftPad; switch (padAlignment) { case FtPadAlignment.Auto: leftPad = definition.AutoLeftPad; break; case FtPadAlignment.Left: leftPad = true; break; case FtPadAlignment.Right: leftPad = false; break; default: throw FtInternalException.Create(InternalError.FtField_PadText_UnsupportedPadAlignment, padAlignment.ToString()); } int padLength; string padText; string result; switch (padCharType) { case FtPadCharType.Auto: case FtPadCharType.Specified: char usePadChar; if (padCharType == FtPadCharType.Auto) { usePadChar = definition.AutoPadChar; } else { usePadChar = padChar; } padLength = definition.Width - text.Length; padText = new string(usePadChar, padLength); if (leftPad) { result = padText + text; } else { result = text + padText; } break; case FtPadCharType.EndOfValue: padLength = definition.Width - text.Length - 1; padText = new string(padChar, padLength); if (leftPad) { result = padText + endOfValueChar.ToString() + text; } else { result = text + endOfValueChar.ToString() + padText; } break; default: throw FtInternalException.Create(InternalError.FtField_PadText_UnsupportedPadCharType, padCharType.ToString()); } return(result); }
internal protected virtual void LoadMeta(FtMetaField metaField, CultureInfo myCulture, int myMainHeadingIndex) { dataType = metaField.DataType; id = metaField.Id; metaName = metaField.Name; metaHeadings = metaField.Headings; mainHeadingIndex = myMainHeadingIndex; culture = myCulture; fixedWidth = metaField.FixedWidth; width = metaField.Width; constant = metaField.Constant; _null = metaField.Null; valueQuotedType = metaField.ValueQuotedType; valueAlwaysWriteOptionalQuote = metaField.ValueAlwaysWriteOptionalQuote; valueWritePrefixSpace = metaField.ValueWritePrefixSpace; valuePadAlignment = metaField.ValuePadAlignment; valuePadCharType = metaField.ValuePadCharType; valuePadChar = metaField.ValuePadChar; valueTruncateType = metaField.ValueTruncateType; valueTruncateChar = metaField.ValueTruncateChar; valueEndOfValueChar = metaField.ValueEndOfValueChar; valueNullChar = metaField.ValueNullChar; headingConstraint = metaField.HeadingConstraint; headingQuotedType = metaField.HeadingQuotedType; headingAlwaysWriteOptionalQuote = metaField.HeadingAlwaysWriteOptionalQuote; headingWritePrefixSpace = metaField.HeadingWritePrefixSpace; headingPadAlignment = metaField.HeadingPadAlignment; headingPadCharType = metaField.HeadingPadCharType; headingPadChar = metaField.HeadingPadChar; headingTruncateType = metaField.HeadingTruncateType; headingTruncateChar = metaField.HeadingTruncateChar; headingEndOfValueChar = metaField.HeadingEndOfValueChar; formatter.Culture = culture; if ( ((headingConstraint == FtHeadingConstraint.NameIsMain) || (headingConstraint == FtHeadingConstraint.NameConstant)) && (mainHeadingIndex >= 0) && (mainHeadingIndex < MetaHeadingCount) ) { metaHeadings[mainHeadingIndex] = metaName; } switch (headingPadAlignment) { case FtPadAlignment.Left: headingLeftPad = true; break; case FtPadAlignment.Right: headingLeftPad = false; break; case FtPadAlignment.Auto: headingLeftPad = autoLeftPad; break; default: throw FtInternalException.Create(InternalError.FtFieldFieldDefinition_LoadMeta_UnsupportedHeadingPadAlignment, headingPadAlignment.ToString()); } switch (valuePadAlignment) { case FtPadAlignment.Left: valueLeftPad = true; break; case FtPadAlignment.Right: valueLeftPad = false; break; case FtPadAlignment.Auto: valueLeftPad = autoLeftPad; break; default: throw FtInternalException.Create(InternalError.FtFieldFieldDefinition_LoadMeta_UnsupportedValuePadAlignment, headingPadAlignment.ToString()); } if (fixedWidth) { fixedWidthNullValueText = new string(ValueNullChar, Width); } }