public IEnumerable <NetPlayer> FindPlayers(string name, NameSearchOption searchOption) { string lowerName = name.ToLower(); return(Players.Values.Where(plr => { switch (searchOption) { case NameSearchOption.StartsWith: return plr.Name.ToLower().StartsWith(lowerName); case NameSearchOption.Contains: return plr.Name.ToLower().Contains(lowerName); } throw new NotImplementedException($"NameSearchOption.{searchOption} not implemented."); })); }
public NetPlayer FindPlayer(string name, NameSearchOption searchOption) { return(FindPlayers(name, searchOption).FirstOrDefault()); }