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

34 lines
1.2 KiB
C#
Raw Normal View History

2020-09-08 16:43:44 +08:00
using System.Globalization;
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-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.TryAddSingleton<IComponentIdGenerator, GuidComponentIdGenerator>();
services.TryAddScoped<IconService>();
2020-05-16 23:27:40 +08:00
services.TryAddScoped<InteropService>();
services.TryAddScoped<NotificationService>();
services.TryAddScoped<MessageService>();
services.TryAddScoped<ModalService>();
services.TryAddScoped<DrawerService>();
services.TryAddScoped<ConfirmService>();
2020-09-08 16:43:44 +08:00
CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.CurrentCulture;
return services;
}
}
}