mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-15 09:21:24 +08:00
25 lines
800 B
C#
25 lines
800 B
C#
using System.Net.Http;
|
|
using System.Text.Encodings.Web;
|
|
using AntBlazor.JsInterop;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace AntBlazor
|
|
{
|
|
public static class ServiceCollectionExtensions
|
|
{
|
|
public static IServiceCollection AddAntBlazor(this IServiceCollection services)
|
|
{
|
|
services.TryAddSingleton<HttpClient>();
|
|
services.TryAddScoped<DomEventService>();
|
|
services.TryAddScoped(sp =>
|
|
{
|
|
return new HtmlRenderService(new HtmlRenderer(sp, sp.GetRequiredService<ILoggerFactory>(),
|
|
s => HtmlEncoder.Default.Encode(s)));
|
|
});
|
|
|
|
return services;
|
|
}
|
|
}
|
|
} |