private void SetMessageType()
        {
            bool loop = true;
            Dictionary <string, Action> menus = new Dictionary <string, Action>();

            menus.Add(AppConstant.STR_BIN_MSG, SetBinMsg);
            menus.Add(AppConstant.STR_TXT_MSG, SetTxtMsg);
            menus.Add(AppCommonConstant.STR_QUIT, null);

            while (loop)
            {
                AppCommonUtil.PrintMenu(menus);
                string command = Console.ReadLine().ToLower();
                if (command == AppCommonConstant.STR_QUIT)
                {
                    break;
                }
                if (menus.ContainsKey(command) == true)
                {
                    if (menus[command] != null)
                    {
                        menus[command]();
                        break;
                    }
                    else
                    {
                        Log.Warning($"Invalid command for {command}");
                    }
                }
                else
                {
                    Log.Warning("Unknown command!!!");
                }
            }
        }
        public void Do()
        {
            bool loop = true;
            Dictionary <string, Action> menu = null;

            _hostSimul.ComPortName = "COM3";
            SetBinMsg();

            while (loop)
            {
                if (_hostSimul.MessageType == MessageType.Text)
                {
                    menu = _appTxtMenu;
                }
                else if (_hostSimul.MessageType == MessageType.Binary)
                {
                    menu = _appBinMenu;
                }
                else
                {
                    Log.Warning("Unknown message type");
                }

                if (menu == null)
                {
                    Log.Warning("No menus available");
                    break;
                }

                PrintHostSimulatorInfo(_hostSimul);
                AppCommonUtil.PrintMenu(menu);
                string command = Console.ReadLine().ToLower();;
                if (command == AppCommonConstant.STR_QUIT)
                {
                    break;
                }
                if (menu.ContainsKey(command) == true)
                {
                    if (menu[command] != null)
                    {
                        menu[command]();
                    }
                    else
                    {
                        Log.Warning($"Invalid command for {command}");
                    }
                }
                else
                {
                    Log.Warning("Unknown command!!!");
                }
            }

            _hostSimul.Stop();
            Log.Information("HostSimulExample1 done");
        }
        static void Main(string[] args)
        {
            // https://github.com/serilog/serilog/wiki/AppSettings
            Log.Logger = new LoggerConfiguration().ReadFrom.AppSettings().CreateLogger();

            // serilog seq app.config
            // https://github.com/serilog/serilog-sinks-seq

            Dictionary <string, IExample> exampleTable = new Dictionary <string, IExample>()
            {
                { AppConstant.STR_HOST_SIMULATOR, new HostSimulatorExample1() },
                { AppConstant.STR_MESSAGE_MANAGER, new MessageManagerExample() },
                { AppCommonConstant.STR_QUIT, null }
            };

            while (true)
            {
                AppCommonUtil.PrintExampleMenu(exampleTable);
                string command = Console.ReadLine().ToLower();

                if (command == AppCommonConstant.STR_QUIT)
                {
                    break;
                }
                if (exampleTable.ContainsKey(command) == true)
                {
                    if (exampleTable[command] != null)
                    {
                        exampleTable[command].Do();
                    }
                    else
                    {
                        Log.Warning($"Invalid example for {command}");
                        Console.WriteLine($"Invalid example for {command}");
                    }
                }
                else
                {
                    Log.Warning("Unknown command!!!");
                    Console.WriteLine("Unknown command!!!");
                }
            }

            Log.Information("Main done");
            Log.CloseAndFlush();

            Console.WriteLine("Main done");
        }
        public void Do()
        {
            bool loop = true;

            db  = new LiteDatabase(@"protocol_history.db");
            col = db.GetCollection <TxtCommandResult>("txtcmdresults");

            SetTxtMsg();

            while (loop)
            {
                PrintMessageManagerInfo();
                AppCommonUtil.PrintMenu(_appMenu);
                string command = Console.ReadLine().ToLower();;
                if (command == AppCommonConstant.STR_QUIT)
                {
                    break;
                }
                if (_appMenu.ContainsKey(command) == true)
                {
                    if (_appMenu[command] != null)
                    {
                        _appMenu[command]();
                    }
                    else
                    {
                        Log.Warning($"Invalid command for {command}");
                    }
                }
                else
                {
                    Log.Warning("Unknown command!!!");
                }
            }

            db.Commit();
            Stop();
            Log.Information("MessageManagerExample done");
        }