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

30 lines
1.0 KiB
C#
Raw Normal View History

using System.Net.Http;
using System.Text.Encodings.Web;
using AntDesign;
using AntDesign.JsInterop;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Logging;
namespace Microsoft.Extensions.DependencyInjection
{
public static class ServiceCollectionExtensions
{
public static IServiceCollection AddAntDesign(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>();
services.TryAddScoped<ModalService>();
return services;
}
}
}