Exemplo n.º 1
0
        public static T Get <T>(string guid)
        {
            var service = Registered.FirstOrDefault(s => s.Guid == guid);

            if (service == null)
            {
                return(default(T));
            }

            if (service is T)
            {
                return((T)(object)service);
            }

            return(default(T));
        }
Exemplo n.º 2
0
 public static bool IsRegistered(Service service)
 {
     return(Registered.FirstOrDefault(s => s == service) != null);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Gets a <see cref="CustomRole"/> by type.
 /// </summary>
 /// <param name="t">The <see cref="Type"/> to get.</param>
 /// <returns>The role, or null if it doesn't exist.</returns>
 public static CustomRole Get(Type t) => Registered.FirstOrDefault(r => r.GetType() == t);
Exemplo n.º 4
0
 /// <summary>
 /// Gets a <see cref="CustomRole"/> by name.
 /// </summary>
 /// <param name="name">The name of the role to get.</param>
 /// <returns>The role, or null if it doesn't exist.</returns>
 public static CustomRole Get(string name) => Registered?.FirstOrDefault(r => r.Name == name);
Exemplo n.º 5
0
 /// <summary>
 /// Gets a <see cref="CustomRole"/> by ID.
 /// </summary>
 /// <param name="id">The ID of the role to get.</param>
 /// <returns>The role, or null if it doesn't exist.</returns>
 public static CustomRole Get(int id) => Registered?.FirstOrDefault(r => r.Id == id);