using System; using System.Collections.Generic; using System.Text; using System.Threading.Tasks; namespace AntDesign { public class ConfirmRef : ConfirmRef { public Func OnCancel { get; set; } public Func OnOk { get; set; } internal ConfirmRef(ConfirmOptions config, ModalService service) : base(config, service) { } /// /// 确定 /// /// public async Task TriggerOkAsync(TResult result) { await (_service?.CloseAsync(this) ?? Task.CompletedTask); await (OnOk?.Invoke(result) ?? Task.CompletedTask); } /// /// 取消 /// /// public async Task TriggerCancelAsync(TResult result) { await (_service.CloseAsync(this) ?? Task.CompletedTask); await (OnCancel?.Invoke(result) ?? Task.CompletedTask); } } public class ConfirmRef { public ConfirmOptions Config { get; set; } protected ModalService _service; internal IModalTemplate ModalTemplate { get; set; } public Func OnOpen { get; set; } public Func OnClose { get; set; } public Func OnDestroy { get; set; } internal bool IsCreateByModalService => _service != null; internal ConfirmRef(ConfirmOptions config) { Config = config; } internal ConfirmRef(ConfirmOptions config, ModalService service) { Config = config; _service = service; } /// /// 打开窗体 /// /// public async Task OpenAsync() { await (_service?.OpenAsync(this) ?? Task.CompletedTask); } /// /// 关闭窗体无返回值 /// /// public async Task CloseAsync() { await (_service?.CloseAsync(this) ?? Task.CompletedTask); } public async Task UpdateConfig() { await (_service?.Update(this) ?? Task.CompletedTask); } public async Task UpdateConfig(ConfirmOptions config) { Config = config; await (_service?.Update(this) ?? Task.CompletedTask); } internal TaskCompletionSource TaskCompletionSource { get; set; } } }