private static void GetUserDataFromConsole() { UserData = new ConsoleUserData(); Console.Write("Podaj adres email subskrybowanego konta: "); UserData.EmailAddress = Console.ReadLine(); UserData.Password = new SecureString(); Console.Write("Wprowadź hasło subskrybowanego konta: "); while (true) { ConsoleKeyInfo userInput = Console.ReadKey(true); if (userInput.Key == ConsoleKey.Enter) { break; } else if (userInput.Key == ConsoleKey.Escape) { return; } else if (userInput.Key == ConsoleKey.Backspace) { if (UserData.Password.Length != 0) { UserData.Password.RemoveAt(UserData.Password.Length - 1); } } else { UserData.Password.AppendChar(userInput.KeyChar); Console.Write("*"); } } Console.WriteLine(); UserData.Password.MakeReadOnly(); }
public static ExchangeService ConnectToService(bool traceToFile) { // We use this to get the target Exchange version. ConsoleUserData data = new ConsoleUserData(); ExchangeService service = new ExchangeService(data.Version); //service.PreAuthenticate = true; if (traceToFile) { service.TraceListener = new TraceListener(); } else { service.TraceEnabled = true; service.TraceFlags = TraceFlags.All; service.TraceEnablePrettyPrinting = true; } ConsoleUserData.GetUserDataFromConsoleCredUI(ref service); return(service); }