File: BrowserPlatformServiceCollectionExtensions.cs
Web Access
Project: Microsoft.AspNetCore.Components.Platform.csproj (Microsoft.AspNetCore.Components.Platform)
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
 
using Microsoft.AspNetCore.Components.Platform;
using Microsoft.Extensions.DependencyInjection.Extensions;
 
namespace Microsoft.Extensions.DependencyInjection;
 
/// <summary>
/// Extension methods for registering browser platform services.
/// </summary>
public static class BrowserPlatformServiceCollectionExtensions
{
    /// <summary>
    /// Adds typed browser platform services.
    /// </summary>
    /// <param name="services">The <see cref="IServiceCollection"/> to add services to.</param>
    /// <returns>The <see cref="IServiceCollection"/> so that additional calls can be chained.</returns>
    /// <exception cref="ArgumentNullException"><paramref name="services"/> is <see langword="null"/>.</exception>
    public static IServiceCollection AddBrowserPlatform(this IServiceCollection services)
    {
        ArgumentNullException.ThrowIfNull(services);
 
        services.TryAddScoped<IBrowserPlatform, BrowserPlatform>();
 
        return services;
    }
}