• API Overview
  • EBICS API
  • FinTS API
  • XS2A API
  • SEPA API
Search Results for

    Class SwiftTextLines

    Helper class for working with a block of text lines, such as the multi-line payment purpose field on a German remittance.

    Inheritance
    System.Object
    SwiftTextLines
    Implements
    System.Collections.Generic.IEnumerable<System.String>
    System.Collections.IEnumerable
    System.IComparable
    System.IComparable<SwiftTextLines>
    Inherited Members
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    Namespace: Subsembly.Swift
    Assembly: Subsembly.Sepa.dll
    Syntax
    public class SwiftTextLines : IEnumerable<string>, IEnumerable, IComparable, IComparable<SwiftTextLines>
    Remarks

    This class manages a multi-line text field as an conceptual array of strings. It ensures that leading and trailing whitespace is trimmed from all the lines that it contains. Also, it ensures that it never contains empty lines or even null string references.

    Constructors

    SwiftTextLines()

    Constructs an all empty instance.

    Declaration
    public SwiftTextLines()

    SwiftTextLines(String)

    Constructs a new instance containing a single line of text.

    Declaration
    public SwiftTextLines(string sLine)
    Parameters
    Type Name Description
    System.String sLine

    SwiftTextLines(String, Boolean)

    Declaration
    public SwiftTextLines(string sText, bool fNewLine)
    Parameters
    Type Name Description
    System.String sText
    System.Boolean fNewLine

    SwiftTextLines(String, Int32, Boolean, Boolean)

    Constructs a new instance by splitting up a single text string.

    Declaration
    public SwiftTextLines(string sText, int nMaxChars, bool fNewLine, bool fWordWrap)
    Parameters
    Type Name Description
    System.String sText

    The text that makes up the new text block. If this is null, then the new text block will be empty.

    System.Int32 nMaxChars

    The max number of characters that may be placed on a single line. If the given line exceeds this limit, then it will be broken up into multiple lines.

    System.Boolean fNewLine

    If true, then the text will be splt at new line sequences.

    System.Boolean fWordWrap

    If true, then long lines will be broken up at a blank character, if possible. If false, then lines will be broken up into exactly nMaxChars portions.

    Exceptions
    Type Condition
    System.ArgumentOutOfRangeException

    The parameter nMaxChars was zero or negative.

    SwiftTextLines(String[])

    Constructs a new instance from an array of strings.

    Declaration
    public SwiftTextLines(string[] vsLines)
    Parameters
    Type Name Description
    System.String[] vsLines

    Array of strings that provides the initial content of this text block. If this parameter is null, then the new text block will be empty. Otherwise all non-empty and non-null strings contained in the array are trimmed and become the content of the new text block.

    Properties

    Count

    The actual count of lines.

    Declaration
    public int Count { get; }
    Property Value
    Type Description
    System.Int32

    Item[Int32]

    Direct access to the individual lines in this text block.

    Declaration
    public string this[int nIndex] { get; set; }
    Parameters
    Type Name Description
    System.Int32 nIndex

    The index of the line to retrieve. If this is greater than the number of lines available, then null is returned.

    Property Value
    Type Description
    System.String
    Exceptions
    Type Condition
    System.ArgumentOutOfRangeException

    The given index was less than zero.

    MaxChars

    Provides the number of characters in the longest line contained in this text lines instance.

    Declaration
    public int MaxChars { get; }
    Property Value
    Type Description
    System.Int32

    Methods

    AddEmptyLine()

    Declaration
    public void AddEmptyLine()

    AddLine(String)

    Add a single line at the end of this text block.

    Declaration
    public void AddLine(string sLine)
    Parameters
    Type Name Description
    System.String sLine

    The line to be added. If this is null or an empty string, then nothing will be added.

    AddLine(String, Boolean)

    Add a single line at the end of this text block.

    Declaration
    public void AddLine(string sLine, bool fAddEmptyLines)
    Parameters
    Type Name Description
    System.String sLine

    The line to be added.

    System.Boolean fAddEmptyLines

    If this is true, then an empty string or null will add an empty line. If this is false, then an empty string or null will be ignored.

    AddLine(String, Int32, SwiftTextLines.WrapOption)

    Adds a single text line at the end of this text block.

    Declaration
    public void AddLine(string sLine, int nMaxChars, SwiftTextLines.WrapOption nWrapOption)
    Parameters
    Type Name Description
    System.String sLine

    The line to be added. If this is null or an empty string, then nothing will be added.

    System.Int32 nMaxChars

    The max number of characters that may be placed on a single line. If the given line exceeds this limit, then it will be broken up into multiple lines.

    SwiftTextLines.WrapOption nWrapOption

    Selects how to break a line that is longer than nMaxChars characters.

    Exceptions
    Type Condition
    System.ArgumentOutOfRangeException

    The parameter nMaxChars was zero or negative.

    AddLine(String, Int32, Boolean)

    Adds a single text line at the end of this text block.

    Declaration
    public void AddLine(string sLine, int nMaxChars, bool fWordWrap)
    Parameters
    Type Name Description
    System.String sLine

    The line to be added. If this is null or an empty string, then nothing will be added.

    System.Int32 nMaxChars

    The max number of characters that may be placed on a single line. If the given line exceeds this limit, then it will be broken up into multiple lines.

    System.Boolean fWordWrap

    If true, then any leading or trailing whitespace will be trimmed and long lines will be broken up at a blank character, if possible. If false, then lines will be broken up into exactly nMaxChars portions.

    Exceptions
    Type Condition
    System.ArgumentOutOfRangeException

    The parameter nMaxChars was zero or negative.

    AddLines(String[])

    Declaration
    public void AddLines(string[] vsLines)
    Parameters
    Type Name Description
    System.String[] vsLines

    Array of strings that provides the text lines to be added. If this parameter is null, then nothing will be added. Otherwise all non-empty and non-null strings contained in the array are trimmed and added to this text block.

    AddText(String)

    Declaration
    public void AddText(string sText)
    Parameters
    Type Name Description
    System.String sText

    AddText(String, Int32, Boolean, Boolean)

    Add the given text wrapping it over mutliple lines if necessary.

    Declaration
    public void AddText(string sText, int nMaxChars, bool fNewLine, bool fWordWrap)
    Parameters
    Type Name Description
    System.String sText

    The text to be added.

    System.Int32 nMaxChars

    The max number of characters that may be placed on a single line. If a line exceeds this limit, then it will be broken up into multiple lines.

    System.Boolean fNewLine

    If true, then the text will be split at new line sequences.

    System.Boolean fWordWrap

    If true, then long lines will be broken up at a blank character, if possible. If false, then lines will be broken up into exactly nMaxChars portions.

    Exceptions
    Type Condition
    System.ArgumentOutOfRangeException

    The parameter nMaxChars was zero or negative.

    BreakLines(Int32, Int32)

    Breaks all lines that are longer than the requested max line length into multiple adjacent lines.

    Declaration
    public void BreakLines(int nMaxChars, int nMaxLines = 0)
    Parameters
    Type Name Description
    System.Int32 nMaxChars

    The maximum allowed line length. Lines longer than this length will be broken into multiple adjacent lines.

    System.Int32 nMaxLines

    The max number of resulting lines after breaking them. Any excess lines are discarded in order to match this limit. If this is zero, then no max line limit will be applied.

    Remarks

    The lines will be broken hard at the nMaxChars position. No trimming of leading or trailing whitespace will be done. Thus all whitespace is preserved exactly.

    Clear()

    Clear this text block.

    Declaration
    public void Clear()

    Clone()

    Declaration
    public SwiftTextLines Clone()
    Returns
    Type Description
    SwiftTextLines

    CompareTo(SwiftTextLines)

    Declaration
    public int CompareTo(SwiftTextLines that)
    Parameters
    Type Name Description
    SwiftTextLines that
    Returns
    Type Description
    System.Int32

    CompareTo(Object)

    Declaration
    public int CompareTo(object obj)
    Parameters
    Type Name Description
    System.Object obj
    Returns
    Type Description
    System.Int32

    Equals(Object)

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    System.Object obj
    Returns
    Type Description
    System.Boolean
    Overrides
    System.Object.Equals(System.Object)

    GetEnumerator()

    Declaration
    public IEnumerator GetEnumerator()
    Returns
    Type Description
    System.Collections.IEnumerator

    GetHashCode()

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    System.Int32
    Overrides
    System.Object.GetHashCode()

    IsEmpty()

    Declaration
    public bool IsEmpty()
    Returns
    Type Description
    System.Boolean

    Join(String)

    Declaration
    public string Join(string sNewLine = "")
    Parameters
    Type Name Description
    System.String sNewLine
    Returns
    Type Description
    System.String

    Pack()

    Packs all lines onto a single text line, replacing any new line sequences with a single blank character.

    Declaration
    public string Pack()
    Returns
    Type Description
    System.String

    Pack(Int32)

    Packs all lines onto a single text line without any new line sequence.

    Declaration
    public string Pack(int nMaxChars)
    Parameters
    Type Name Description
    System.Int32 nMaxChars

    Maximum number of characters of a packed line.

    Returns
    Type Description
    System.String
    Remarks

    All lines are joined using the blank character between each line. If a line fills the entire MaxChars, then no blank is appended and it is directly concatenated with the subsequent line.

    PackLines(Int32, Int32)

    Nicely wraps lines to match the requested max line length.

    Declaration
    public bool PackLines(int nMaxChars, int nMaxLines)
    Parameters
    Type Name Description
    System.Int32 nMaxChars
    System.Int32 nMaxLines
    Returns
    Type Description
    System.Boolean

    RemoveAt(Int32)

    Declaration
    public void RemoveAt(int nIndex)
    Parameters
    Type Name Description
    System.Int32 nIndex
    Exceptions
    Type Condition
    System.ArgumentOutOfRangeException

    A line with the given index does not exist in this instance.

    SetLineCount(Int32)

    Declaration
    public void SetLineCount(int nLineCount)
    Parameters
    Type Name Description
    System.Int32 nLineCount

    SetLines(String[])

    Set the content of this text block from an array of strings.

    Declaration
    public void SetLines(string[] vsLines)
    Parameters
    Type Name Description
    System.String[] vsLines

    Array of strings that provides the new content of this text block. If this parameter is null, then this text block is effectively cleared. Otherwise all non-empty and non-null strings contained in the array are trimmed and become the new text block.

    SetText(String)

    Set text with new lines but without word wrapping.

    Declaration
    public void SetText(string sText)
    Parameters
    Type Name Description
    System.String sText

    SetText(String, Int32, Boolean, Boolean)

    Set this text block to the given text, wrapping it over mutliple lines if necessary.

    Declaration
    public void SetText(string sText, int nMaxChars, bool fNewLine, bool fWordWrap)
    Parameters
    Type Name Description
    System.String sText

    The text to be set.

    System.Int32 nMaxChars

    The max number of characters that may be placed on a single line. If a line exceeds this limit, then it will be broken up into multiple lines.

    System.Boolean fNewLine

    If true, then the text will be splt at new line sequences.

    System.Boolean fWordWrap

    If true, then long lines will be broken up at a blank character, if possible. If false, then lines will be broken up into exactly nMaxChars portions.

    Exceptions
    Type Condition
    System.ArgumentException

    The parameter sNewLine was an empty string. Use null if you do not want to split at newline sequences.

    System.ArgumentOutOfRangeException

    The parameter nMaxChars was zero or negative.

    ToArray()

    Declaration
    public string[] ToArray()
    Returns
    Type Description
    System.String[]

    ToString()

    Declaration
    public override string ToString()
    Returns
    Type Description
    System.String
    Overrides
    System.Object.ToString()

    TrimLines()

    Declaration
    public void TrimLines()

    TrimTrailingEmptyLines()

    Declaration
    public void TrimTrailingEmptyLines()

    Operators

    Equality(SwiftTextLines, SwiftTextLines)

    Declaration
    public static bool operator ==(SwiftTextLines lhs, SwiftTextLines rhs)
    Parameters
    Type Name Description
    SwiftTextLines lhs
    SwiftTextLines rhs
    Returns
    Type Description
    System.Boolean

    Inequality(SwiftTextLines, SwiftTextLines)

    Declaration
    public static bool operator !=(SwiftTextLines lhs, SwiftTextLines rhs)
    Parameters
    Type Name Description
    SwiftTextLines lhs
    SwiftTextLines rhs
    Returns
    Type Description
    System.Boolean

    Explicit Interface Implementations

    IEnumerable<String>.GetEnumerator()

    Declaration
    IEnumerator<string> IEnumerable<string>.GetEnumerator()
    Returns
    Type Description
    System.Collections.Generic.IEnumerator<System.String>

    Implements

    System.Collections.Generic.IEnumerable<T>
    System.Collections.IEnumerable
    System.IComparable
    System.IComparable<T>
    In This Article
    Back to top Copyright 2009-2025 Subsembly GmbH