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)); }
public static bool IsRegistered(Service service) { return(Registered.FirstOrDefault(s => s == service) != null); }
/// <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);
/// <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);
/// <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);