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