using System; using System.Collections.Generic; using System.Text; using System.Threading.Tasks; using Microsoft.AspNetCore.Components; namespace AntDesign { public class ConfirmTemplate : TemplateComponentBase, IModalTemplate { [Parameter] public ConfirmRef ConfirmRef { get; set; } /// /// Emit Ok and return values /// /// public async Task OnOkAsync(TResult result) { await (ConfirmRef.OnOk?.Invoke(result) ?? Task.CompletedTask); } /// /// Emit Cancel and return values /// /// public async Task OnCancelAsync(TResult result) { await (ConfirmRef.OnCancel?.Invoke(result) ?? Task.CompletedTask); } /// /// Close the Modal /// /// protected async Task CloseAsync() { await ConfirmRef.CloseAsync(); } protected override void OnInitialized() { base.OnInitialized(); ConfirmRef.ModalTemplate = this; } public virtual Task CancelAsync(ModalClosingEventArgs args) { return Task.CompletedTask; } public virtual Task OkAsync(ModalClosingEventArgs args) { return Task.CompletedTask; } } }