Implementation of a command-line parsing class. Is capable of having switches registered with it directly or can examine a registered class for any properties with the appropriate attributes appended to them.
示例#1
0
 public void AutoLoadWithQuotes()
 {
     CommandLine commandLine = new CommandLine();
     Parser parser = new Parser("DummyProgram.exe /SourceDir:\"c:\\Program Files\"", commandLine);
     parser.Parse();
     Assert.AreEqual("c:\\Program Files", commandLine.SourceDirectory, "The source parameter is not correct.");
 }
示例#2
0
 public void ParseStringWithoutQuotesAndOneParam()
 {
     Parser parser = new Parser( "Jee.exe test", this);
     parser.Parse();
     Assert.AreEqual("Jee.exe",parser.ApplicationName);
     Assert.AreEqual(1, parser.Parameters.Length );
 }
示例#3
0
		public void ParseStringWithoutQuotesAndParamWithQuotes()
		{
			Parser parser = new Parser( "Jee.exe test3 \'test1 test2\' test4", this);
			parser.Parse();
			Assert.AreEqual("Jee.exe",parser.ApplicationName);
			Assert.AreEqual(3,parser.Parameters.Length);
		}
示例#4
0
        public static void Main(string[] args)
        {
            Console.WriteLine("UDP Producer test");

            if (args.Length == 0)
            {
                System.Console.WriteLine(CommandLineArguments.Usage());
                return;
            }

            log4net.Config.BasicConfigurator.Configure();

            CommandLineArguments cliArgs = new CommandLineArguments();
            Parser parser = new Parser(System.Environment.CommandLine, cliArgs);
            parser.Parse();

            int numberOfMessages = 10;
            string message = "Hello, how are you?";

            while ((numberOfMessages--) != 0)
            {
                System.Console.WriteLine("Publishing UDP message");
                NetBrokerMessage brokerMessage = new NetBrokerMessage(System.Text.Encoding.UTF8.GetBytes(message));
                BrokerClient.PublishMessageOverUdp(brokerMessage, cliArgs.DestinationName, new HostInfo(cliArgs.Hostname, cliArgs.PortNumber), BrokerClient.DefaultMessageSerializer);
                System.Threading.Thread.Sleep(500);
            }
        }
示例#5
0
		public void ParseStringWithQuotesAndTwoParams()
		{
			Parser parser = new Parser( "'C:\\Program Files\\Microsoft Virtual PC\\Virtual PC.exe' test1 test2", this);
			parser.Parse();
			Assert.AreEqual("C:\\Program Files\\Microsoft Virtual PC\\Virtual PC.exe",parser.ApplicationName);
			Assert.AreEqual( 2, parser.Parameters.Length);
		}
示例#6
0
		/// <summary>
		/// This is the entry point into the DLL.  It parses the command line and
		/// delegates the work out to each program.
		/// </summary>
		/// <param name="commandLine">The commandline that invoked the program.  Usually
		/// this corresponds to System.Environment.CommandLine</param>
		/// <returns></returns>
		public static void DllMain(string commandLine)
		{
			CommandLine = new CommandLine();
			Parser parser = new Parser(commandLine, CommandLine);			
			parser.Parse();

			if(CommandLine.Help)
			{
				Console.WriteLine("This program is used to import blog data from other blogging programs.");
				Console.WriteLine("  Note that this program will modify your content directory so back it up.");
				Console.WriteLine("  Also, the program will require an internet connection in some instances, ");
				Console.WriteLine("  like importing comments from an external server.");
				Console.WriteLine( parser.GetHelpText() );
			}
			else
			{
				switch(CommandLine.Source)
				{
					case BlogSourceType.Radio:
						if(CommandLine.SourceDirectory !=  null && CommandLine.SourceDirectory.Length > 0
							&& CommandLine.ContentDirectory != null && CommandLine.ContentDirectory.Length > 0)
						{
							Console.WriteLine("Importing entries from Radio...");
							DasBlog.Import.Radio.EntryImporter.Import(
								CommandLine.SourceDirectory,
								CommandLine.ContentDirectory);
						}
						else
						{
							Console.WriteLine("Entries from Radio not imported because either source directory or content directory were not specified.");
						}
						
						if(CommandLine.UserID != null && CommandLine.UserID.Length > 0 
							&& CommandLine.ContentDirectory != null && CommandLine.ContentDirectory.Length > 0)

						{
							if(CommandLine.CommentServer != null && CommandLine.CommentServer.Length > 0)
							{
								Console.WriteLine("Defaulting to comment server {0}.  You may need to check your radio source.  radiocomments2, etc",DasBlog.Import.Radio.CommentImporter.DefaultCommentServer);
							}

							Console.WriteLine("BETA: Importing comments from Radio...");
							DasBlog.Import.Radio.CommentImporter.Import(
								CommandLine.UserID, CommandLine.ContentDirectory, CommandLine.CommentServer );
						}
						else
						{
							Console.WriteLine("Comments from Radio not imported because comment server, userid or content directory were not specified.");
						}


						break;
					case BlogSourceType.none:
						goto default;
					default:
						throw new ApplicationException(
							string.Format("The source option was not specified or else was invalid."));
				}
			}
		}
示例#7
0
 public void ParseStringWithDoubleQuotesAndParamWithQuote()
 {
     Parser parser = new Parser( "\"C:\\Program Files\\Microsoft Virtual PC\\Virtual PC.exe\" 'test1 test2'", this);
     parser.Parse();
     Assert.AreEqual("C:\\Program Files\\Microsoft Virtual PC\\Virtual PC.exe",parser.ApplicationName);
     Assert.AreEqual( 1, parser.Parameters.Length);
 }
        public static void Main(string[] args)
        {
            Console.WriteLine("MultipleProducers test");

            if (args.Length == 0)
            {
                System.Console.WriteLine(CommandLineArguments.Usage());
                return;
            }

            log4net.Config.BasicConfigurator.Configure();

            CommandLineArguments cliArgs = new CommandLineArguments();
            Parser parser = new Parser(System.Environment.CommandLine, cliArgs);
            parser.Parse();

            BrokerClient brokerClient = new BrokerClient(new HostInfo(cliArgs.Hostname, cliArgs.PortNumber));
            int numberOfMessages = 500000;

            Thread[] threads = new System.Threading.Thread[NR_THREADS];

            for (int i = 0; i != threads.Length; ++i)
            {
                threads[i] = new Thread(
                    new ThreadStart(() =>
                    {
                        int msgs = numberOfMessages;
                        int threadId = i;

                        while ((--msgs) != 0)
                        {
                            int msgId = Interlocked.Increment(ref message_id);
                            string message = String.Format("{0} - Thread id: {1}", msgId, threadId);
                            NetBrokerMessage brokerMessage = new NetBrokerMessage(System.Text.Encoding.UTF8.GetBytes(message));

                            System.Console.WriteLine(message);
                            if (cliArgs.DestinationType == NetAction.DestinationType.TOPIC)
                            {
                                brokerClient.Publish(brokerMessage, cliArgs.DestinationName);
                            }
                            else
                            {
                                brokerClient.Enqueue(brokerMessage, cliArgs.DestinationName);
                            }
                        }
                    }
                )
                );

                threads[i].Start();

            }

            Console.WriteLine("Write X to unsbscribe and exit");
            while (!System.Console.Read().Equals('X'))
                ;
        }
        public static void Main(string[] args)
        {
            Console.WriteLine("ConsumerWithAutoAck test");

            if (args.Length == 0)
            {
                System.Console.WriteLine(CommandLineArguments.Usage());
                return;
            }

            CommandLineArguments cliArgs = new CommandLineArguments();
            Parser parser = new Parser(System.Environment.CommandLine, cliArgs);
            parser.Parse();

            BrokerClient brokerClient = new BrokerClient(new HostInfo(cliArgs.Hostname, cliArgs.PortNumber));

            Subscription subscription = new Subscription(cliArgs.DestinationName, cliArgs.DestinationType);

            if (cliArgs.DestinationType != NetAction.DestinationType.TOPIC)
            {
                // Set AutoAcknowledge
                subscription.AutoAcknowledge = true;
            }

            int i = 0;
            subscription.OnMessage += delegate(NetNotification notification)
            {
                System.Console.WriteLine("Message received: {0}, Total: {1}",
                                         System.Text.Encoding.UTF8.GetString(notification.Message.Payload), (++i).ToString());
                /*
                 *  AutoAcknowledge is enable, so, there is no need to excplicit acknowledge message
                 *
                if (notification.DestinationType != NetAction.DestinationType.TOPIC)
                {
                    brokerClient.Acknowledge(notification);
                }
                 */
            };

            brokerClient.Subscribe(subscription);

            Console.WriteLine("Write X to unsbscribe and exit");
            while (!System.Console.Read().Equals('X'))
                ;
            Console.WriteLine();
            Console.WriteLine("Unsubscribe...");

            // Note Subscription instance could other than the one used for subscription as long as it was equivelent (same destination type and subscription pattern). Since the application is ending and therefor the socket will be closed agent's will discard the previous subscription.
            brokerClient.Unsubscribe(subscription);

            Console.WriteLine("Good bye");
        }
示例#10
0
        public static void Main(string[] args)
        {
            Console.WriteLine("SSL Consumer test");

            if (args.Length == 0)
            {
                System.Console.WriteLine(CommandLineArguments.Usage());
                return;
            }

            CommandLineArguments cliArgs = new CommandLineArguments();
            Parser parser = new Parser(System.Environment.CommandLine, cliArgs);
            parser.Parse();

            X509CertificateCollection certCollection = null;
            if (cliArgs.CertificatePath != null)
            {
                X509Certificate cert = X509Certificate.CreateFromCertFile(cliArgs.CertificatePath);

                certCollection = new X509CertificateCollection();
                certCollection.Add(cert);
            }

            SslBrokerClient brokerClient = new SslBrokerClient(new HostInfo(cliArgs.Hostname, cliArgs.PortNumber), certCollection);

            Subscription subscription = new Subscription(cliArgs.DestinationName, cliArgs.DestinationType);
            subscription.OnMessage += delegate(NetNotification notification)
            {
                System.Console.WriteLine("Message received: {0}",
                                         System.Text.Encoding.UTF8.GetString(notification.Message.Payload));
                if (notification.DestinationType != NetAction.DestinationType.TOPIC)
                    brokerClient.Acknowledge(notification.Subscription, notification.Message.MessageId);
                if (notification.DestinationType != NetAction.DestinationType.TOPIC)
                {
                    brokerClient.Acknowledge(notification);
                }
            };

            brokerClient.Subscribe(subscription);

            Console.WriteLine("Write X to unsbscribe and exit");
            while (!System.Console.Read().Equals('X'))
                ;
            Console.WriteLine();
            Console.WriteLine("Unsubscribe...");

            // Note Subscription instance could other than the one used for subscription as long as it was equivelent (same destination type and subscription pattern). Since the application is ending and therefor the socket will be closed agent's will discard the previous subscription.
            brokerClient.Unsubscribe(subscription);

            Console.WriteLine("Good bye");
        }
        public static void Main(string[] args)
        {
            Console.WriteLine("Consumer with failover test");

            if (args.Length == 0)
            {
                System.Console.WriteLine(CommandLineArguments.Usage());
                return;
            }

            CommandLineArguments cliArgs = new CommandLineArguments();
            Parser parser = new Parser(System.Environment.CommandLine, cliArgs);
            parser.Parse();

            List<HostInfo> hosts = new List<HostInfo>();
            hosts.Add(new HostInfo(cliArgs.Hostname, cliArgs.PortNumber));
            //hosts.Add(new HostInfo(cliArgs.Hostname, 3423)); // Add an alternative

            BrokerClient brokerClient = new BrokerClient(hosts);
            Subscription subscription = new Subscription(cliArgs.DestinationName, cliArgs.DestinationType);
            subscription.OnMessage += delegate(NetNotification notification)
            {
                System.Console.WriteLine("Message received: {0}",
                                         System.Text.Encoding.UTF8.GetString(notification.Message.Payload));
                if (notification.DestinationType != NetAction.DestinationType.TOPIC)
                {
                    brokerClient.Acknowledge(notification);
                }
            };

            brokerClient.Subscribe(subscription);

            Console.WriteLine("Write X to unsbscribe and exit");
            while (!System.Console.Read().Equals('X'))
                ;
            Console.WriteLine();
            Console.WriteLine("Unsubscribe...");

            // Note Subscription instance could other than the one used for subscription as long as it was equivelent (same destination type and subscription pattern). Since the application is ending and therefor the socket will be closed agent's will discard the previous subscription.
            brokerClient.Unsubscribe(subscription);

            Console.WriteLine("Good bye");
        }
示例#12
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Ping test");

            if (args.Length == 0)
            {
                System.Console.WriteLine(CommandLineArguments.Usage());
                return;
            }

            CommandLineArguments cliArgs = new CommandLineArguments();
            Parser parser = new Parser(System.Environment.CommandLine, cliArgs);
            parser.Parse();

            BrokerClient brokerClient = new BrokerClient(new HostInfo(cliArgs.Hostname, cliArgs.PortNumber));

            NetPong pong = brokerClient.Ping();

            Console.WriteLine("Pong was null? {0}", pong == null);
        }
示例#13
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Producer test");

            if (args.Length == 0)
            {
                System.Console.WriteLine(CommandLineArguments.Usage());
                return;
            }

            log4net.Config.BasicConfigurator.Configure();

            CommandLineArguments cliArgs = new CommandLineArguments();
            Parser parser = new Parser(System.Environment.CommandLine, cliArgs);
            parser.Parse();

            BrokerClient brokerClient = new BrokerClient(new HostInfo(cliArgs.Hostname, cliArgs.PortNumber));

            PublishMessages(brokerClient, cliArgs.DestinationName, 100, cliArgs.DestinationType);
        }
示例#14
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Poll test");

            if (args.Length == 0)
            {
                System.Console.WriteLine(CommandLineArguments.Usage());
                return;
            }

            log4net.Config.BasicConfigurator.Configure();

            CommandLineArguments cliArgs = new CommandLineArguments();
            Parser parser = new Parser(System.Environment.CommandLine, cliArgs);
            parser.Parse();

            BrokerClient brokerClient = new BrokerClient(new HostInfo(cliArgs.Hostname, cliArgs.PortNumber));
            while (true)
            {
                try
                {
                    //NetNotification notification = brokerClient.Poll(cliArgs.DestinationName); // Wait forever
                    //NetNotification notification = brokerClient.Poll(cliArgs.DestinationName, 0, 30000, null); //Wait forever, Reserve time: 30s, No Accept Request.
                    NetNotification notification = brokerClient.Poll(cliArgs.DestinationName, 2000);
                    if (notification != null)
                    {
                        System.Console.WriteLine("Message received: {0}",
                                                     System.Text.Encoding.UTF8.GetString(notification.Message.Payload));
                        brokerClient.Acknowledge(notification.Destination, notification.Message.MessageId);
                    }
                    else
                    {
                        Console.WriteLine("No message received");
                    }
                }
                catch (TimeoutException te)
                {
                    Console.WriteLine("Message timedout...", te);
                }
            }
        }
示例#15
0
        public void GetHelpText()
        {
            string expectedText =
                "DummyProgramName.exe [/SourceType:Radio] [/{ContentDir|to}] [/{SourceDir|from}] [/Help] \n\n" +
                "	/SourceType       -Specify the blog program from which to import content.\n" +
                "	/ContentDir       -The DasBlog content directory into which the entries are placed.\n" +
                "                              Aliases: to\n" +
                "	/SourceDir        -The source directory from which content will be imported.\n" +
                "                              Aliases: from\n" +
                "	/Help             -Displays the command line help.\n";

            CommandLine commandLine= new CommandLine();
            Parser parser = new Parser("DummyProgramName.exe /Help", commandLine);
            parser.Parse();
            Console.WriteLine("Actual:\n" + parser.GetHelpText());
            Console.WriteLine("\nExpected:\n" + expectedText);

            Assert.IsTrue(commandLine.Help, "The CommandLine was unexpectedly not set to true when using the '/Help' parameters.");

            Assert.AreEqual(
                expectedText,
                parser.GetHelpText(),
                "The help text returned was not as expected.");
        }
示例#16
0
 public void QuotesTest2()
 {
     Parser parser = new Parser( "'C:\\Program Files\\Microsoft Virtual PC\\Virtual PC.exe' /p'test1' /a'test2'", this);
     parser.Parse();
     Assert.AreEqual("C:\\Program Files\\Microsoft Virtual PC\\Virtual PC.exe",parser.ApplicationName);
     Assert.AreEqual(2, parser.Parameters.Length);
 }
        public static void Main(string[] args)
        {
            Console.WriteLine("ConsumerWithNoAckRequired test");

            if (args.Length == 0)
            {
                System.Console.WriteLine(CommandLineArguments.Usage());
                return;
            }

            CommandLineArguments cliArgs = new CommandLineArguments();
            Parser parser = new Parser(System.Environment.CommandLine, cliArgs);
            parser.Parse();

            BrokerClient brokerClient = new BrokerClient(new HostInfo(cliArgs.Hostname, cliArgs.PortNumber));

            Subscription subscription = new Subscription(cliArgs.DestinationName, cliArgs.DestinationType);

            if (cliArgs.DestinationType != NetAction.DestinationType.TOPIC)
            {
                subscription.SetHeader("ACK_REQUIRED", "false");
            }

            int i = 0;
            subscription.OnMessage += delegate(NetNotification notification)
            {
                System.Console.WriteLine("Message received: {0}, Total: {1}",
                                         System.Text.Encoding.UTF8.GetString(notification.Message.Payload), (++i).ToString());

                IDictionary<string, string> headers = notification.Headers;
                if (headers.Keys != null)
                {
                    System.Console.WriteLine("Headers:");

                    foreach (string header in headers.Keys)
                    {
                        System.Console.WriteLine("{0} - {1}", header, headers[header]);
                    }
                }

                /*
                 *  ACK IS NOT REQUIRED because ACK_REQUIRED was set to false.
                 *
                if (notification.DestinationType != NetAction.DestinationType.TOPIC)
                {
                    brokerClient.Acknowledge(notification);
                }
                 */
            };

            brokerClient.Subscribe(subscription);

            Console.WriteLine("Write X to unsbscribe and exit");
            while (!System.Console.Read().Equals('X'))
                ;
            Console.WriteLine();
            Console.WriteLine("Unsubscribe...");

            // Note Subscription instance could other than the one used for subscription as long as it was equivelent (same destination type and subscription pattern). Since the application is ending and therefor the socket will be closed agent's will discard the previous subscription.
            brokerClient.Unsubscribe(subscription);

            Console.WriteLine("Good bye");
        }
示例#18
0
        private int Run(string[] cmdLine)
        {
            // Initialise the command line parser, passing in a reference to this
            // class so that we can look for any attributes that implement
            // command line switches.
            Parser parser = new Parser(System.Environment.CommandLine, this);

            // Programmatically add some switches to the command line parser.
            parser.AddSwitch("Wibble", "Do something silly");

            // Add a switches with lots of aliases for the first name, "help" and "a".
            parser.AddSwitch(new string[] { "help", @"\?" }, "show help");
            parser.AddSwitch(new string[] { "a", "b", "c", "d", "e", "f" }, "Early alphabet");

            // Parse the command line.
            parser.Parse();

            // ----------------------- DEBUG OUTPUT -------------------------------
            Console.WriteLine("Program Name      : {0}", parser.ApplicationName);
            Console.WriteLine("Non-switch Params : {0}", parser.Parameters.Length);
            for (int j = 0; j < parser.Parameters.Length; j++)
                Console.WriteLine("                {0} : {1}", j, parser.Parameters[j]);
            Console.WriteLine("----");
            Console.WriteLine("Value of ShowSomeHelp    : {0}", ShowSomeHelp);
            Console.WriteLine("Value of m_SomethingElse : {0}", m_SomethingElse);
            Console.WriteLine("Value of UserName        : {0}", UserName);
            Console.WriteLine("----");

            // Walk through all of the registered switches getting the available
            // information back out.
            Parser.SwitchInfo[] si = parser.Switches;
            if (si != null)
            {
                Console.WriteLine("There are {0} registered switches:", si.Length);
                foreach (Parser.SwitchInfo s in si)
                {
                    Console.WriteLine("Command : {0} - [{1}]", s.Name, s.Description);
                    Console.Write("Type    : {0} ", s.Type);

                    if (s.IsEnum)
                    {
                        Console.Write("- Enums allowed (");
                        foreach (string e in s.Enumerations)
                            Console.Write("{0} ", e);
                        Console.Write(")");
                    }
                    Console.WriteLine();

                    if (s.Aliases != null)
                    {
                        Console.Write("Aliases : [{0}] - ", s.Aliases.Length);
                        foreach (string alias in s.Aliases)
                            Console.Write(" {0}", alias);
                        Console.WriteLine();
                    }

                    Console.WriteLine("------> Value is : {0} (Without any callbacks {1})\n",
                        s.Value != null ? s.Value : "(Unknown)",
                        s.InternalValue != null ? s.InternalValue : "(Unknown)");
                }
            }
            else
                Console.WriteLine("There are no registered switches.");

            // Test looking for a specificly named values.
            Console.WriteLine("----");
            if (parser["help"] != null)
                Console.WriteLine("Request for help = {0}", parser["help"]);
            else
                Console.WriteLine("Request for help has no associated value.");
            Console.WriteLine("User Name is {0}", parser["name"]);

            // Note the difference between the parser and a callback value.
            Console.WriteLine("The property of test (/test) is internally is read-only, " +
                                    "e.g. no update can be made by the parser:\n" +
                                    "   -- The indexer gives a value of : {0}\n" +
                                    "   -- Internally the parser has    : {1}",
                                    parser["test"],
                                    parser.InternalValue("test"));

            // Test if the enumeration value has changed to Friday!
            if (DoW == DaysOfWeek.Fri)
                Console.WriteLine("\nYeah Friday.... PUB LUNCH TODAY...");

            // For error handling, were any switches handled?
            string[] unhandled = parser.UnhandledSwitches;
            if (unhandled != null)
            {
                Console.WriteLine("\nThe following switches were not handled.");
                foreach (string s in unhandled)
                    Console.WriteLine("  - {0}", s);
            }

            // To access non-switch parameters
            // what remains is split (by the parser) into white-space delimited (or quoted) strings, in the property Parameters
            // BUG: the following command-line switches/parameters will not be correctly processed,
            // because the quote is erroneously aggressive
            //   /user "New Name" --age 32 a b "c D"
            Console.WriteLine("Non-switch Params : {0}", parser.Parameters.Length);
            for (int j = 0; j < parser.Parameters.Length; j++)
                Console.WriteLine("{0} : {1}", j, parser.Parameters[j]);

            return 0;
        }
示例#19
0
 // [Test, ExpectedException(typeof(System.ApplicationException)), Ignore("Not yet supported")]
 public void InvalidEnumSpecified()
 {
     CommandLine commandLine= new CommandLine();
     Parser parser = new Parser("DummyProgramName.exe /Source:InvalidSource", commandLine);
     parser.Parse();
 }
示例#20
0
        public static void Main(string[] args)
        {
            Console.WriteLine("BrokerDB authenticated Consumer test");

            if (args.Length == 0)
            {
                System.Console.WriteLine(CommandLineArguments.Usage());
                return;
            }

            CommandLineArguments cliArgs = new CommandLineArguments();
            Parser parser = new Parser(System.Environment.CommandLine, cliArgs);
            parser.Parse();

            BasicConfigurator.Configure();

            X509CertificateCollection certCollection = null;
            if (cliArgs.CertificatePath != null)
            {
                X509Certificate cert = X509Certificate.CreateFromCertFile(cliArgs.CertificatePath);

                certCollection = new X509CertificateCollection();
                certCollection.Add(cert);
            }

            List<HostInfo> hosts = new List<HostInfo>();
            hosts.Add(new HostInfo(cliArgs.Hostname, cliArgs.SslPortNumber));

            SslBrokerClient brokerClient = new SslBrokerClient(hosts, certCollection);

            brokerClient.OnFault += (f) =>
            {
                Console.WriteLine("Error");
                Console.WriteLine(String.Format("Code: {0}, Message: {1}, Detail: {2}", f.Code, f.Message, f.Detail));
            };

            ICredentialsProvider provider = new BrokerDbProvider("luis", "luis");

            Console.WriteLine("Authenticating");
            if (!brokerClient.Authenticate(provider))
            {
                Console.WriteLine("Authentication failed");
                return;
            }

            Subscription subscription = new Subscription(cliArgs.DestinationName, cliArgs.DestinationType);
            subscription.OnMessage += delegate(NetNotification notification)
            {
                System.Console.WriteLine("Message received: {0}",
                                         System.Text.Encoding.UTF8.GetString(notification.Message.Payload));
                if (notification.DestinationType != NetAction.DestinationType.TOPIC)
                    brokerClient.Acknowledge(notification.Subscription, notification.Message.MessageId);
            };

            brokerClient.Subscribe(subscription);

            Console.WriteLine("Write X to unsbscribe and exit");
            while (!System.Console.Read().Equals('X'))
                ;
            Console.WriteLine();
            Console.WriteLine("Unsubscribe...");

            // Note Subscription instance could other than the one used for subscription as long as it was equivelent (same destination type and subscription pattern). Since the application is ending and therefor the socket will be closed agent's will discard the previous subscription.
            brokerClient.Unsubscribe(subscription);

            Console.WriteLine("Good bye");
        }
示例#21
0
 public void QuotesTest4()
 {
     Parser parser = new Parser( "\"C:\\Program Files\\Microsoft Virtual PC\\Virtual PC.exe\" /p:\"test1\" /a:\"test2\"", this);
     parser.Parse();
     Assert.AreEqual("C:\\Program Files\\Microsoft Virtual PC\\Virtual PC.exe",parser.ApplicationName);
     Assert.AreEqual(2, parser.Parameters.Length);
 }