/// <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); }