static void Main(string[] args) { XmlStorageTypes.Register <Exception>(); XmlStorageTypes.Register <StateObject>(); XmlStorageTypes.Register <Response>(); MessageFactory.Instance.Register <LoginMessage>(); Console.Clear(); if ((args?.Length ?? 0) < 1) { Console.WriteLine("Brak argumentu uruchomieniowego!\n1 - serwer\n2 - klient"); } else { int _iMode = 0; int.TryParse(args[0], out _iMode); switch (_iMode) { case 1: new TestServer().Run(); break; case 2: new TestClient().Run(); break; } } }
static void Main(string[] args) { Console.Clear(); Log.CurrentLevel = Log.LevelEnum.DEB; using var _log = Log.DEB("Program", "Main"); _log.PR_DEB("Początek aplikacji"); if ((args?.Length ?? 0) < 1) { _log.PR_DEB("Brak argumentu uruchomieniowego! 1 - serwer, 2 - klient"); } else { int.TryParse(args[0], out int _iMode); XmlStorageTypes.Register <Exception>(); MessageFactory.Instance.Register <LoginMessage>(); MessageFactory.Instance.Register <TextMessage>(); switch (_iMode) { case 1: new TestServer().Run(); break; case 2: new TestClient().Run(); break; } } }
static void Main(string[] args) { XmlStorageTypes.Register <Exception>(); //client LoginMessage _loginObj = new LoginMessage(); /* * { * Login = "******" * }; */ //server _loginObj.ProcessRequest(); string _sXml = Encoding.UTF8.GetString(_loginObj.ToXml().ToArray()); Console.WriteLine(); Console.WriteLine(_sXml); Console.WriteLine(); //client try { LoginMessage _loginObj2 = new LoginMessage(); _loginObj2.FromXml(new MemoryStream(Encoding.UTF8.GetBytes(_sXml))); _loginObj2.ProcessResponse(); } catch (Exception e) { Console.WriteLine($"Wystąpił wyjątek! {e.Message}"); } Console.ReadKey(); }