/// <summary> /// Gets required service. Throws exception if such is not found or there are no registered services. /// </summary> /// <typeparam name="TInstance">Type of requested service.</typeparam> /// <returns>Instance of TInstance type.</returns> public static TInstance GetRequiredService <TInstance>() { ServiceValidator.ValidateServices(); var service = Current.GetService <TInstance>(); ServiceValidator.ValidateServiceExists(service); return(service); }
/// <summary> /// Gets collection of services. Returns null if no service of this type is not found. Throws exception if there are no registered services. /// </summary> /// <typeparam name="TInstance">Type of requested service.</typeparam> /// <returns>Instance of TInstance type.</returns> public static IEnumerable <TInstance> GetServices <TInstance>() { ServiceValidator.ValidateServices(); return(Current.GetServices <TInstance>()); }
/// <summary> /// Gets service. Returns null if such is not found. Throws exception if there are no registered services. /// </summary> /// <typeparam name="TInstance">Type of requested service.</typeparam> /// <returns>Instance of TInstance type.</returns> public static TInstance GetService <TInstance>() { ServiceValidator.ValidateServices(); return(Current.GetService <TInstance>()); }