ant-design-blazor/components/core/ServiceCollectionExtensions.cs

29 lines
977 B
C#
Raw Normal View History

using System.Net.Http;
using System.Text.Encodings.Web;
using AntBlazor;
2019-12-16 18:48:03 +08:00
using AntBlazor.JsInterop;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Logging;
namespace Microsoft.Extensions.DependencyInjection
{
public static class ServiceCollectionExtensions
{
public static IServiceCollection AddAntBlazor(this IServiceCollection services)
{
2019-12-13 12:43:16 +08:00
services.TryAddSingleton<HttpClient>();
2019-12-16 18:48:03 +08:00
services.TryAddScoped<DomEventService>();
services.TryAddScoped(sp => new HtmlRenderService(new HtmlRenderer(sp, sp.GetRequiredService<ILoggerFactory>(),
s => HtmlEncoder.Default.Encode(s)))
);
services.TryAddScoped<IconService>();
2020-05-16 23:27:40 +08:00
services.TryAddScoped<InteropService>();
services.TryAddScoped<NotificationService>();
services.TryAddScoped<MessageService>();
return services;
}
}
}