/// <summary> /// Creates the field format based on the field name, format string, padding direction, total width and padding char. /// </summary> /// <param name="name">The name of the field.</param> /// <param name="format">The format string.</param> /// <param name="paddingDir">The padding direction.</param> /// <param name="totalWidth">The total width.</param> /// <param name="paddingChar">The padding char.</param> public FieldFormat(string name, string format, PaddingDirection paddingDir, int totalWidth, char paddingChar) { this.Name = name; this.Format = format; this.PaddingDir = paddingDir; this.TotalWidth = totalWidth; this.PaddingChar = paddingChar; }
/// <summary> /// Creates the field format based on the field name, format string, padding direction, total width and padding char. /// </summary> /// <param name="name">The name of the field.</param> /// <param name="format">The format string.</param> /// <param name="paddingDir">The padding direction.</param> /// <param name="totalWidth">The total width.</param> /// <param name="paddingChar">The padding char.</param> public FieldFormat(string name, string format, PaddingDirection paddingDir, int totalWidth, char paddingChar) { Name = name; Format = format; PaddingDir = paddingDir; TotalWidth = totalWidth; PaddingChar = paddingChar; }
/// <summary> /// Add an FieldFormat object based the field name, format string, padding direction, total width and padding char. /// </summary> /// <param name="name">The name of the field.</param> /// <param name="format">The format string of the field.</param> /// <param name="paddingDir">The padding direction.</param> /// <param name="totalWidth">The total width.</param> /// <param name="paddingChar">The padding char.</param> public void Add(string name, string format, PaddingDirection paddingDir, int totalWidth, char paddingChar) { List.Add(new FieldFormat(name, format, paddingDir, totalWidth, paddingChar)); }
private string ApplyPadding(string paddedValue, PaddingDirection direction, char character, int width) { return(direction == PaddingDirection.Left ? paddedValue.PadLeft(width, character) : paddedValue.PadRight(width, character)); }