using System; using System.Collections.Generic; using System.Text; using System.Threading.Tasks; namespace AntDesign { public class ModalRef : ModalRef { public Func OnCancel { get; set; } public Func OnOk { get; set; } internal ModalRef(ConfirmOptions config, ModalService service) : base(config, service) { } /// /// 确定 /// /// public async Task TriggerOkAsync(TResult result) { await _service?.CloseAsync(this); await OnOk?.Invoke(result); } /// /// 取消 /// /// public async Task TriggerCancelAsync(TResult result) { await _service?.CloseAsync(this); await OnCancel?.Invoke(result); } } public class ModalRef { public ConfirmOptions Config { get; set; } public Drawer Drawer { 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 ModalRef(ConfirmOptions config) { Config = config; } internal ModalRef(ConfirmOptions config, ModalService service) { Config = config; _service = service; } /// /// 打开窗体 /// /// public async Task OpenAsync() { await _service?.OpenAsync(this); } /// /// 关闭窗体无返回值 /// /// public async Task CloseAsync() { await _service?.CloseAsync(this); } public async Task UpdateConfig() { await _service?.Update(this); } public async Task UpdateConfig(ConfirmOptions config) { Config = config; await _service?.Update(this); } } }