using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace AntDesign
{
///
///
///
public class ConfirmRef : FeedbackRefWithOkCancelBase
{
#region internal
internal bool IsCreateByModalService => Service != null;
internal TaskCompletionSource TaskCompletionSource { get; set; }
internal ConfirmRef(ConfirmOptions config)
{
Config = config;
}
internal ConfirmRef(ConfirmOptions config, ModalService service)
{
Config = config;
Service = service;
}
#endregion
///
///
///
protected ModalService Service { get; set; }
///
/// Confirm dialog options
///
public ConfirmOptions Config { get; private set; }
#region base inheritdoc
///
/// close Confirm dialog
///
///
public override async Task CloseAsync()
{
await (Service?.DestroyConfirmAsync(this) ?? Task.CompletedTask);
}
///
/// Open Confirm dialog
///
///
public override async Task OpenAsync()
{
await (Service?.OpenConfirmAsync(this) ?? Task.CompletedTask);
}
///
/// update Confirm dialog config which Visible=true
///
///
public override async Task UpdateConfigAsync()
{
await (Service?.UpdateConfirmAsync(this) ?? Task.CompletedTask);
}
///
/// update Confirm dialog config with a new ConfirmOptions
///
///
///
public async Task UpdateConfigAsync(ConfirmOptions config)
{
Config = config;
await UpdateConfigAsync();
}
#endregion
}
///
/// ConfirmRef for
///
///
public class ConfirmRef : ConfirmRef, IOkCancelRef
{
internal ConfirmRef(ConfirmOptions config, ModalService service) : base(config, service)
{
}
///
public new Func OnCancel { get; set; }
///
public new Func OnOk { get; set; }
///
public async Task OkAsync(TResult result)
{
await (OnOk?.Invoke(result) ?? Task.CompletedTask);
}
///
public async Task CancelAsync(TResult result)
{
await (OnCancel?.Invoke(result) ?? Task.CompletedTask);
}
}
}