static void Main(string[] args) { ManagementHelper helper = new ManagementHelper(ServiceBusConnectionString); bool done = false; do { Console.ForegroundColor = ConsoleColor.Cyan; Console.Write(">"); string commandLine = Console.ReadLine(); Console.ForegroundColor = ConsoleColor.Magenta; string[] commands = commandLine.Split(' '); try { if (commands.Length > 0) { switch (commands[0]) { case "createqueue": case "cq": if (commands.Length > 1) { helper.CreateQueue(commands[1]); } else { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Queue path not specified."); } break; case "listqueues": case "lq": helper.ListQueues(); break; case "getqueue": case "gq": if (commands.Length > 1) { helper.GetQueue(commands[1]); } else { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Queue path not specified."); } break; case "deletequeue": case "dq": if (commands.Length > 1) { helper.DeleteQueue(commands[1]); } else { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Queue path not specified."); } break; case "createtopic": case "ct": if (commands.Length > 1) { helper.CreateTopic(commands[1]); } else { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Queue path not specified."); } break; case "createsubscription": case "cs": if (commands.Length > 2) { helper.CreateSubscription(commands[1], commands[2]); } else { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Queue path not specified."); } break; case "listtopics": case "lt": helper.ListTopicsAndSubscriptions(); break; case "exit": done = true; break; default: break; } } } catch (Exception ex) { Console.WriteLine(); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(ex.Message); } } while (!done); }
static void Main(string[] args) { ManagementHelper helper = new ManagementHelper(ServiceBusConnectionString); bool done = false; do { Console.ForegroundColor = ConsoleColor.Cyan; Console.Write(">"); string commandLine = Console.ReadLine(); Console.ForegroundColor = ConsoleColor.Magenta; string[] commands = commandLine.Split(' '); try{ if (commands.Length > 0) { switch (commands[0]) { case "cq": if (commands.Length > 1) { helper.CreateQueue(commands[1]); } else { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Queue Path missing"); } break; case "lq": if (commands.Length > 1) { helper.ListQueue(commands[1]); } else if (commands.Length == 1) { helper.ListQueues(); } else { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Queue Path missing"); } break; case "dq": if (commands.Length > 1) { helper.DeleteQueue(commands[1]); } else { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Queue Path missing"); } break; case "ls": helper.ListTopicsAndSubscription(); break; case "ct": if (commands.Length > 1) { helper.CreateTopic(commands[1]); } else { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Topic Path missing"); } break; case "cs": if (commands.Length > 2) { helper.CreateSubscription(commands[1], commands[2]); } else { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Subsription Path missing"); } break; case "exit": done = true; break; } } } catch (Exception ex) { Console.WriteLine("Error {0}", ex.Message); } } while(!done); Console.ReadKey(); }