Lately I received a couple of emails if it is possible to use SharpMt940Lib for other banks than ABN Amro. When I designed the library I kept this requirement in mind, but since I only had data from ABN AMRO and some spec files I need to do some guesses and assumptions.

There were only two variable elements I found in the specification files, the header and footer of the MT940 files, both exist of a couple of lines of strings.

For example ABN Amro has the following header:

ABNANL2A
940
ABNANL2A

And as footer

-

So if we encapsulate the variables in an interface, we end up with something like this:

using System;

namespace Raptorious.Finance.Swift.Mt940Format
{
    /// 
    /// Every bank defines it's own header and trailer in it's MT940 format.
    /// Implement this interface per specific bank.
    /// 
    public interface IMt940Format
    {
        Seperator Header { get; }   
        Seperator Trailer { get; }
    }
}

If we implement it for ABN Amro we need to inherrit IMt940Format and it becomes like this:

using System;

namespace Raptorious.Finance.Swift.Mt940Format
{
    /// 
    /// IMt940Format implementation for Abn Amro.
    /// 
    /// 
    public class AbnAmro : IMt940Format
    {
        /// 
        /// Header property
        /// 
        /// ABN Amro defines it's header as such:
        /// ABNANL2A[newline]
        /// 940[newline]
        /// ABNANL2A
        /// 
        public Seperator Header
        {
            get;
            private set;
        }

        /// 
        /// Trailer
        /// 
        /// 
        /// ABN Amro defines it's trailer as -
        /// 
        /// 
        public Seperator Trailer
        {
            get;
            private set;
        }

        public AbnAmro()
        {
            Header = new  Seperator ( "ABNANL2A", "940", "ABNANL2A" );
            Trailer = new Seperator ("-");
        }
    }

}

So when we want a different bank, we create a new class and just add a new seperator. So if a bank defines its header as:

SOMEBANK
40
SOMEBANK

We will have the following header:

Header = new  Seperator ( "SOMEBANK", "940", "SOMEBANK" );

If you find issues or have questions you can submit them at https://bitbucket.org/raptux/sharpmt940lib/issues or contact me directly.