/// <summary>
        /// Main function, receiving structured command-line arguments
        /// via the System.Console.DragonFruit package.
        /// For example: dotnet run -- --domain-id 54 --sample-count 5
        /// </summary>
        /// <param name="domainId">The domain ID to create the DomainParticipant</param>
        /// <param name="sampleCount">The number of data samples to publish</param>
        public static void Main(int domainId = 0, int sampleCount = int.MaxValue)
        {
            var example = new ChocolateFactorySubscriber();

            // Setup signal handler
            Console.CancelKeyPress += (_, eventArgs) =>
            {
                Console.WriteLine("Shuting down...");
                eventArgs.Cancel          = true; // let the application shutdown gracefully
                example.shutdownRequested = true;
            };

            try
            {
                example.RunExample(domainId, sampleCount);
            }
            catch (Exception ex)
            {
                Console.WriteLine("RunExample exception: " + ex.Message);
                Console.WriteLine(ex.StackTrace);
            }
        }
        /// <summary>
        /// The Main function runs the publisher or the subscriber.
        /// </summary>
        public static void Main(string[] args)
        {
            var arguments = ParseArguments(args);

            if (arguments == null)
            {
                return;
            }

            if (arguments.Verbose)
            {
                Logger.Instance.SetVerbosity(Verbosity.Warning);
            }

            IChocolateFactoryApplication application;

            if (arguments.Pub)
            {
                Console.WriteLine($"Running ChocolateFactoryPublisher on domain {arguments.Domain}");
                application = new ChocolateFactoryPublisher(arguments.SensorId);
            }
            else
            {
                Console.WriteLine($"Running ChocolateFactorySubscriber on domain {arguments.Domain}");
                application = new ChocolateFactorySubscriber();
            }

            // Set up signal handler to Dispose the DDS entities
            Console.CancelKeyPress += (_, eventArgs) =>
            {
                Console.WriteLine("Shutting down...");
                eventArgs.Cancel = true; // let the application shutdown gracefully
                application.Stop();
            };

            application.Run(arguments.Domain, arguments.SampleCount);
        }