static void SetTrace(CommonArguments args)
 {
     if (Trace.TraceListener == null)
     {
         Trace.TraceLevel    = args.Trace.ToTraceLevel();
         Trace.TraceListener = (l, f, a) => Console.WriteLine(DateTime.Now.ToString("[hh:mm:ss.fff]") + " " + string.Format(f, a));
     }
 }
Exemple #2
0
        static void Run(string[] args)
        {
            bool            writeUsage = false;
            IRunnable       role       = null;
            CommonArguments commonArgs = null;

            if (args.Length > 0)
            {
                if (args.Length == 1)
                {
                    writeUsage = true;
                }

                if (string.Equals("send", args[0], StringComparison.OrdinalIgnoreCase))
                {
                    Publisher publisher = new Publisher(args, 1);
                    commonArgs = publisher.Args;
                    role       = publisher;
                }
                else if (string.Equals("receive", args[0], StringComparison.OrdinalIgnoreCase))
                {
                    Consumer consumer = new Consumer(args, 1);
                    commonArgs = consumer.Args;
                    role       = consumer;
                }
                else
                {
                    writeUsage = true;
                }
            }
            else
            {
                writeUsage = true;
            }

            if (writeUsage)
            {
                if (commonArgs == null)
                {
                    Console.WriteLine("LongHaulText.ext send|receive [options]");
                }
                else
                {
                    Arguments.PrintArguments(commonArgs.GetType());
                }
            }
            else
            {
                role.Run();
            }
        }