Beispiel #1
0
 /// <summary> Returns all servers with the specified name. </summary>
 /// <remarks> Search is case-insensitive. </remarks>
 public IEnumerable <Server> FindServers(string name)
 {
     if (name == null)
     {
         return(new Server[0]);
     }
     return(_servers.Where(x =>
                           string.Equals(x.Name, name, StringComparison.OrdinalIgnoreCase)));
 }
Beispiel #2
0
        /// <summary> Returns all roles with the specified server and name. </summary>
        /// <remarks> Name formats supported: Name and @Name. Search is case-insensitive. </remarks>
        public IEnumerable <Role> FindRoles(string serverId, string name)
        {
            if (serverId == null || name == null)
            {
                return(new Role[0]);
            }

            if (name.StartsWith("@"))
            {
                string name2 = name.Substring(1);
                return(_roles.Where(x => x.ServerId == serverId &&
                                    string.Equals(x.Name, name, StringComparison.OrdinalIgnoreCase) || string.Equals(x.Name, name2, StringComparison.OrdinalIgnoreCase)));
            }
            else
            {
                return(_roles.Where(x => x.ServerId == serverId &&
                                    string.Equals(x.Name, name, StringComparison.OrdinalIgnoreCase)));
            }
        }
Beispiel #3
0
        /// <summary> Returns the user with the specified name and discriminator, or null if none was found. </summary>
        /// <remarks> Name formats supported: Name and @Name. Search is case-insensitive. </remarks>
        public User GetUser(string name, string discriminator)
        {
            if (name == null || discriminator == null)
            {
                return(null);
            }

            if (name.StartsWith("@"))
            {
                name = name.Substring(1);
            }

            return(_users
                   .Where(x =>
                          string.Equals(x.Name, name, StringComparison.OrdinalIgnoreCase) &&
                          x.Discriminator == discriminator
                          )
                   .FirstOrDefault());
        }