//return true if existing or false if new client had to be added private bool GetClient(string alias, out ClientLog client) { //use 4Tell in place of a blank alias if ((alias == null) || (alias.Length < 1)) alias = "4Tell"; if (m_clients.Count > 0) { foreach (ClientLog c in m_clients) if (c.Alias.Equals(alias)) //found { client = c; //set reference to this client return true; } } //client not found client = new ClientLog(alias, m_dataPath); m_clients.Add(client); return false; }
//return true if existing or false if new client had to be added public bool GetClient(string alias, out ClientLog client, bool add = true) { client = null; //use 4Tell in place of a blank alias if ((alias == null) || (alias.Length < 1)) alias = "4Tell"; if (m_clients.Count > 0) { foreach (ClientLog c in m_clients) if (c.Alias.Equals(alias)) //found { client = c; //set reference to this client return true; } } //client not found if (add) { client = new ClientLog(alias); m_clients.Add(client); } return false; }