private void LoadRecentServersSetting() { if (_settings?.RemoteServers == null) { return; } _recentServers = new ObservableCollection <ServerInfo>(); IEnumerable <string> serversAndPorts = Helpers.SplitWithEscape(';', _settings.RemoteServers); lock (RecentServers) { foreach (string serverStr in serversAndPorts) { List <string> tokens = Helpers.SplitWithEscape(':', serverStr); if (tokens.Count < 2) { continue; } ServerInfo info = new ServerInfo(tokens[0], System.Convert.ToUInt16(tokens[1])); RecentServers.Add(info); } } }
public void AddRecent(Server server) { var recentServer = new RecentServer(server, DateTime.Now); if (RecentServers.Count > 50) { var oldest = RecentServers.OrderBy(x => x.On).FirstOrDefault(); RecentServers.Remove(oldest); } RecentServers.Add(recentServer); recentServer.Server = server; App.Events.Publish(new RecentAdded(recentServer)); Save(); }