protected function tryRegisterProviders($on)
    {
        if ($on === $this->registerProvidersOn && $this->registerProvidersMethod === self::METHOD_REGISTER) {
            // FIRST register all given providers
            foreach ($this->providers as $provider) {
                $this->app->register($provider);
            }

            foreach ($this->deferredProviders as $provider) {
                $this->app->registerDeferredProvider($provider);
            }
        } elseif ($this->registerProvidersMethod === self::METHOD_RESOLVE) {
            foreach ($this->providers as $provider) {
                $resolved = $this->app->resolveProviderClass($registered[] = $provider);
                if ($on === self::ON_REGISTER) {
                    $resolved->register();
                } elseif ($on === self::ON_BOOT) {
                    $this->app->call([$provider, 'boot']);
                }
            }
        }
    }