diff --git a/components/core/Extensions/ServiceCollectionExtensions.cs b/components/core/Extensions/ServiceCollectionExtensions.cs index 16b45a2c..f879bf0c 100644 --- a/components/core/Extensions/ServiceCollectionExtensions.cs +++ b/components/core/Extensions/ServiceCollectionExtensions.cs @@ -32,6 +32,7 @@ namespace Microsoft.Extensions.DependencyInjection services.TryAddScoped(); services.TryAddScoped(); services.TryAddScoped(); + services.TryAddScoped(provider => provider.GetRequiredService()); services.TryAddScoped(); services.TryAddScoped(); services.TryAddSingleton(); diff --git a/components/modal/confirmDialog/ConfirmService.cs b/components/modal/confirmDialog/ConfirmService.cs index 83b9a3ae..ec6685ee 100644 --- a/components/modal/confirmDialog/ConfirmService.cs +++ b/components/modal/confirmDialog/ConfirmService.cs @@ -10,7 +10,7 @@ namespace AntDesign /// /// show a simple Confirm dialog like MessageBox of Windows, it's different from ModalService. ModalService can only create OK-Cancel Confirm dialog and return ConfirmRef, but ConfirmService return ConfirmResult /// - public class ConfirmService + public class ConfirmService : IConfirmService { internal event Func OnOpenEvent; diff --git a/components/modal/confirmDialog/IConfirmService.cs b/components/modal/confirmDialog/IConfirmService.cs new file mode 100644 index 00000000..30148fd9 --- /dev/null +++ b/components/modal/confirmDialog/IConfirmService.cs @@ -0,0 +1,23 @@ +using System; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Components; +using OneOf; + +namespace AntDesign; + +public interface IConfirmService +{ + Task Show( + OneOf content, + OneOf title, + ConfirmButtons confirmButtons, + ConfirmIcon confirmIcon, + ConfirmButtonOptions options, + ConfirmAutoFocusButton? autoFocusButton = ConfirmAutoFocusButton.Ok); + + Task Show + (OneOf content, + OneOf title, + ConfirmButtons confirmButtons = ConfirmButtons.OKCancel, + ConfirmIcon confirmIcon = ConfirmIcon.Info); +} diff --git a/site/AntDesign.Docs/Demos/Components/Drawer/demo/Drawer_event.razor b/site/AntDesign.Docs/Demos/Components/Drawer/demo/Drawer_event.razor index 10586536..784d7825 100644 --- a/site/AntDesign.Docs/Demos/Components/Drawer/demo/Drawer_event.razor +++ b/site/AntDesign.Docs/Demos/Components/Drawer/demo/Drawer_event.razor @@ -1,5 +1,5 @@ @inject DrawerService DrawerService -@inject ConfirmService confirmService +@inject IConfirmService confirmService diff --git a/site/AntDesign.Docs/Demos/Components/Modal/demo/Confirm_Service.razor b/site/AntDesign.Docs/Demos/Components/Modal/demo/Confirm_Service.razor index 7b6cc45b..192bc13d 100644 --- a/site/AntDesign.Docs/Demos/Components/Modal/demo/Confirm_Service.razor +++ b/site/AntDesign.Docs/Demos/Components/Modal/demo/Confirm_Service.razor @@ -1,5 +1,5 @@ @inject IMessageService _message -@inject ConfirmService _confirmService +@inject IConfirmService _confirmService Buttons diff --git a/site/AntDesign.Docs/Demos/Components/Modal/demo/OverrideLocale.razor b/site/AntDesign.Docs/Demos/Components/Modal/demo/OverrideLocale.razor index a238484d..cb798667 100644 --- a/site/AntDesign.Docs/Demos/Components/Modal/demo/OverrideLocale.razor +++ b/site/AntDesign.Docs/Demos/Components/Modal/demo/OverrideLocale.razor @@ -1,4 +1,4 @@ -@inject ConfirmService _confirmService +@inject IConfirmService _confirmService @inject ModalService _modalService diff --git a/site/AntDesign.Docs/Demos/Components/Modal/demo/confirm_service.md b/site/AntDesign.Docs/Demos/Components/Modal/demo/confirm_service.md index f5956f9b..5cf820b6 100644 --- a/site/AntDesign.Docs/Demos/Components/Modal/demo/confirm_service.md +++ b/site/AntDesign.Docs/Demos/Components/Modal/demo/confirm_service.md @@ -7,8 +7,8 @@ title: ## zh-CN -使用 `ConfirmService.Show` 可以快捷地弹出一个内置的确认框,类似于 Windows MessageBox。 +使用 `IConfirmService.Show` 可以快捷地弹出一个内置的确认框,类似于 Windows MessageBox。 ## en-US -Use `ConfirmService.Show` to show a built-in confirm dialog, similar to Windows MessageBox. +Use `IConfirmService.Show` to show a built-in confirm dialog, similar to Windows MessageBox. diff --git a/site/AntDesign.Docs/Demos/Components/Modal/doc/index.en-US.md b/site/AntDesign.Docs/Demos/Components/Modal/doc/index.en-US.md index 10cc94e2..ae64fd69 100644 --- a/site/AntDesign.Docs/Demos/Components/Modal/doc/index.en-US.md +++ b/site/AntDesign.Docs/Demos/Components/Modal/doc/index.en-US.md @@ -87,7 +87,7 @@ There are some ways to display the information based on the content's nature: ### ConfirmService -`ConfirmService.Show` to show a simple Confirm dialog like MessageBox of Windows, it's different from ModalService. ModalService can only create OK-Cancel Confirm dialog and return ConfirmRef or OK button is clicked, but ConfirmService return ConfirmResult. +`IConfirmService.Show` to show a simple Confirm dialog like MessageBox of Windows, it's different from ModalService. ModalService can only create OK-Cancel Confirm dialog and return ConfirmRef or OK button is clicked, but ConfirmService return ConfirmResult. #### ConfirmOptions diff --git a/site/AntDesign.Docs/Demos/Components/Modal/doc/index.zh-CN.md b/site/AntDesign.Docs/Demos/Components/Modal/doc/index.zh-CN.md index 7493eb3b..a1824100 100644 --- a/site/AntDesign.Docs/Demos/Components/Modal/doc/index.zh-CN.md +++ b/site/AntDesign.Docs/Demos/Components/Modal/doc/index.zh-CN.md @@ -89,7 +89,7 @@ cover: https://gw.alipayobjects.com/zos/alicdn/3StSdUlSH/Modal.svg ### ConfirmService -`ConfirmService.Show` 用于弹出类似于在WinForm中使用 MessageBox 方式弹出的对话框。这和 ModalService 不同的是,ModalService 只可以创建 具有 OK-Cancel 按钮的对话框并返回 ConfirmRef 对象或者是否OK按钮被点击,而 ConfirmService 总是返回 ConfirmResult ,以指示哪个按钮被点击。 +`IConfirmService.Show` 用于弹出类似于在WinForm中使用 MessageBox 方式弹出的对话框。这和 ModalService 不同的是,ModalService 只可以创建 具有 OK-Cancel 按钮的对话框并返回 ConfirmRef 对象或者是否OK按钮被点击,而 ConfirmService 总是返回 ConfirmResult ,以指示哪个按钮被点击。 #### ConfirmOptions diff --git a/site/AntDesign.Docs/Demos/Components/Tag/demo/Event.razor b/site/AntDesign.Docs/Demos/Components/Tag/demo/Event.razor index ad2a8840..8404fd91 100644 --- a/site/AntDesign.Docs/Demos/Components/Tag/demo/Event.razor +++ b/site/AntDesign.Docs/Demos/Components/Tag/demo/Event.razor @@ -1,4 +1,4 @@ -@inject ConfirmService _confirmService +@inject IConfirmService _confirmService
onClosing