Exemplo n.º 1
0
 private static void BeginTask(string command, DwollaBroker broker)
 {
     if (!_tasks.ContainsKey(command))
     {
         WriteLine("Unrecognized option");
     }
     else
     {
         var type = _tasks[command];
         var task = (BaseTask)type.GetConstructor(new Type[0]).Invoke(new object[0]);
         task.Broker = broker;
         Task.Run(async() => await task.Run()).Wait();
     }
 }
Exemplo n.º 2
0
        private static void Main()
        {
            var key    = Environment.GetEnvironmentVariable("DWOLLA_APP_KEY");
            var secret = Environment.GetEnvironmentVariable("DWOLLA_APP_SECRET");

            if (string.IsNullOrWhiteSpace(key) || string.IsNullOrWhiteSpace(secret))
            {
                WriteLine("Set DWOLLA_APP_KEY and DWOLLA_APP_SECRET env vars and restart IDE. Press any key to exit..");
                ReadLine();
            }
            else
            {
                var running = true;
                var broker  = new DwollaBroker(DwollaClient.Create(true));

                Task.Run(async() => await broker.SetAuthorizationHeader(key, secret)).Wait();

                WriteHelp();

                while (running)
                {
                    Write("What would you like to do? (Press ? for options): ");
                    var i     = ReadLine();
                    var input = i == null ? "" : i.ToLower().Trim();

                    switch (input)
                    {
                    case "?":
                        WriteHelp();
                        break;

                    case "quit":
                    case "q":
                    case "exit":
                        running = false;
                        break;

                    default:
                        BeginTask(input, broker);
                        break;
                    }
                }
            }
        }