/// <summary> /// open the Confirm dialog /// </summary> /// <param name="confirmRef"></param> /// <returns></returns> internal async Task OpenConfirmAsync(ConfirmRef confirmRef) { if (OnConfirmOpenEvent != null) { await OnConfirmOpenEvent.Invoke(confirmRef); } }
/// <summary> /// create and open a OK-Cancel Confirm dialog /// </summary> /// <param name="props"></param> /// <returns></returns> public ConfirmRef Confirm(ConfirmOptions props) { CheckConfirmOptionsIsNull(props); ConfirmRef confirmRef = new ConfirmRef(props, this); confirmRef.TaskCompletionSource = new TaskCompletionSource <ConfirmResult>(); OnConfirmOpenEvent?.Invoke(confirmRef); return(confirmRef); }
/// <summary> /// create and open a OK-Cancel Confirm dialog, /// and return a bool value which indicates whether the OK button has been clicked /// </summary> /// <param name="props"></param> /// <returns></returns> public async Task <bool> ConfirmAsync(ConfirmOptions props) { ConfirmRef confirmRef = new ConfirmRef(props, this); confirmRef.TaskCompletionSource = new TaskCompletionSource <ConfirmResult>(); if (OnConfirmOpenEvent != null) { await OnConfirmOpenEvent.Invoke(confirmRef); } return(await confirmRef.TaskCompletionSource.Task .ContinueWith(t => t.Result == ConfirmResult.OK, TaskScheduler.Default)); }
/// <summary> /// Create and open template Confirm dialog /// </summary> /// <typeparam name="TComponent"></typeparam> /// <typeparam name="TComponentOptions"></typeparam> /// <typeparam name="TResult"></typeparam> /// <param name="config"></param> /// <param name="componentOptions"></param> /// <returns></returns> public Task <ConfirmRef <TResult> > CreateConfirmAsync <TComponent, TComponentOptions, TResult>(ConfirmOptions config, TComponentOptions componentOptions) where TComponent : ConfirmTemplate <TComponentOptions, TResult> { CheckConfirmOptionsIsNull(config); ConfirmRef <TResult> confirmRef = new ConfirmRef <TResult>(config, this); OnConfirmOpenEvent?.Invoke(confirmRef); RenderFragment child = (builder) => { builder.OpenComponent <TComponent>(0); builder.AddAttribute(1, "ConfirmRef", confirmRef); builder.AddAttribute(2, "Options", componentOptions); builder.CloseComponent(); }; config.Content = child; return(Task.FromResult(confirmRef)); }