Skip to content

Commit

Permalink
leverage generic GetService
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed Nov 21, 2024
1 parent 4c83776 commit 8d9fdbc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static IApplicationBuilder UseIdentityServer(this IApplicationBuilder app

internal static void Validate(this IApplicationBuilder app)
{
var loggerFactory = app.ApplicationServices.GetService(typeof(ILoggerFactory)) as ILoggerFactory;
var loggerFactory = app.ApplicationServices.GetService<ILoggerFactory>();
if (loggerFactory == null) throw new ArgumentNullException(nameof(loggerFactory));

var logger = loggerFactory.CreateLogger("Duende.IdentityServer.Startup");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Microsoft.Extensions.Logging;
using System;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;

namespace Duende.IdentityServer.Hosting.FederatedSignOut;

Expand All @@ -24,7 +25,7 @@ public AuthenticationRequestHandlerWrapper(IAuthenticationRequestHandler inner,
_inner = inner;
_context = httpContextAccessor.HttpContext;

var factory = (ILoggerFactory)_context.RequestServices.GetService(typeof(ILoggerFactory));
var factory = _context.RequestServices.GetService<ILoggerFactory>();
_logger = factory?.CreateLogger(GetType());
}

Expand Down

0 comments on commit 8d9fdbc

Please sign in to comment.