示例#1
0
        /// <inheritdoc />
        public IPlayer GetOnlinePlayerById(string id)
        {
            IEnumerable <EcoPlayer> players = OnlinePlayers.Cast <EcoPlayer>();

            return(players.FirstOrDefault(x => x.Id.Equals(id))
                   ?? throw new EcoPlayerNotFoundException(id));
        }
示例#2
0
        /// <inheritdoc />
        public IPlayer GetOnlinePlayerByName(string name)
        {
            IEnumerable <EcoPlayer> players = OnlinePlayers.Cast <EcoPlayer>();

            return(players.FirstOrDefault(x => x.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase))
                   ?? players.FirstOrDefault(x => x.Name.ComparerContains(name))
                   ?? throw new EcoPlayerNotFoundException(name));
        }
示例#3
0
        /// <inheritdoc />
        public bool TryGetOnlinePlayerById(string id, out IPlayer output)
        {
            IEnumerable <EcoPlayer> players = OnlinePlayers.Cast <EcoPlayer>();

            EcoPlayer player = players.FirstOrDefault(x => x.Id.Equals(id));

            output = player;

            return(player != null);
        }
示例#4
0
        /// <inheritdoc />
        public bool TryGetOnlinePlayerByName(string name, out IPlayer output)
        {
            IEnumerable <EcoPlayer> players = OnlinePlayers.Cast <EcoPlayer>();

            EcoPlayer player = players.FirstOrDefault(x => x.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase))
                               ?? players.FirstOrDefault(x => x.Name.ComparerContains(name));

            output = player;

            return(player != null);
        }