×
Menu

Implementation Example

 
The following is complete implementation of a command line application that works in the same way as SwiftCmd
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SoftwareBureau.SortMessages;
using SoftwareBureau.SwiftAPI;
namespace SoftwareBureau.SwiftAPICmd
{
    class Program
    {
        private static void sort_AuditMessageReceived(object sender, TSBMessageEventArgs e)
        {
            Console.WriteLine(String.Format("[Message]: {0}", e.Str));
        }
 
        private static void sort_StatusChanged(object sender, TSBStatusChangedEventArgs e)
        {
            SortProcessingStage stage = (SortProcessingStage)e.Phase;
            Console.WriteLine("[Status]: " + stage.ToString() + "(" + e.Progress.ToString() + ")");
        }
 
        static void Main(string[] args)
        {
            StatusChangedEventHandler statusChanged = new SoftwareBureau.SortMessages.StatusChangedEventHandler(sort_StatusChanged);
            AuditMessageReceivedHandler messageReceived = new AuditMessageReceivedHandler(sort_AuditMessageReceived);
 
            SwiftSortAPI api = new SwiftSortAPI();
            int result = api.RunSort(statusChanged, messageReceived, args);
 
            if (result != 0)
                Console.WriteLine(String.Format("Error code {0} returned", result));
        }
    }
}