Skip to content

Commit

Permalink
Merge pull request #1631 from SimonCropp/leverage-generic-GetService
Browse files Browse the repository at this point in the history
leverage generic GetService
  • Loading branch information
damianh authored Nov 27, 2024
2 parents fa17d98 + 8d9fdbc commit 44b7dc5
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 44b7dc5

Please sign in to comment.