// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; using System.Collections.Generic; using System.Text; using System.Threading.Tasks; using Microsoft.AspNetCore.Components; using OneOf; namespace AntDesign { /// /// NotificationRef /// public class NotificationRef : FeedbackRefBase { /// /// the notification box's config /// public NotificationConfig Config { get; private set; } private readonly NotificationService _service; internal NotificationRef(NotificationService service,NotificationConfig config) { _service = service; Config = config; } /// /// open the notification box /// /// public override async Task OpenAsync() { await _service.InternalOpen(Config); if (OnOpen != null) await OnOpen.Invoke(); } /// /// After modifying the Config property, update the notification box /// /// public override async Task UpdateConfigAsync() { await _service.UpdateAsync(Config.Key, Config.Description, Config.Message); } /// /// update the notification box's description /// /// /// public async Task UpdateConfigAsync(OneOf description) { Config.Description = description; await UpdateConfigAsync(); } /// /// update the notification box's description and message /// /// /// /// public async Task UpdateConfigAsync(OneOf description, OneOf message) { Config.Description = description; Config.Message = message; await UpdateConfigAsync(); } /// /// close the notification box /// /// public override async Task CloseAsync() { await _service.Close(Config.Key); if (OnClose != null) await OnClose.Invoke(); } } }