Ejemplo n.º 1
0
        public static OpenIddictCoreBuilder UseEpiManagers(this OpenIddictCoreBuilder builder)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            builder.ReplaceApplicationManager(typeof(EpiOpenIdApplicationManager <>));
            builder.ReplaceScopeManager(typeof(EpiOpenIdScopeManager <>));
            builder.ReplaceAuthorizationManager(typeof(EpiOpenIdAuthorizationManager <>));
            builder.ReplaceTokenManager(typeof(EpiOpenIdTokenManager <>));

            builder.Services.TryAddScoped(provider => (IEpiOpenIdApplicationManager)
                                          provider.GetRequiredService <IOpenIddictApplicationManager>());
            builder.Services.TryAddScoped(provider => (IEpiOpenIdScopeManager)
                                          provider.GetRequiredService <IOpenIddictScopeManager>());
            builder.Services.TryAddScoped(provider => (IEpiOpenIdAuthorizationManager)
                                          provider.GetRequiredService <IOpenIddictAuthorizationManager>());
            builder.Services.TryAddScoped(provider => (IEpiOpenIdTokenManager)
                                          provider.GetRequiredService <IOpenIddictTokenManager>());

            return(builder);
        }