using JetBrains.Annotations; using System; using System.Collections.Generic; using Volo.Abp; using Volo.Abp.Localization; namespace Sanhe.Abp.Notifications; /// /// 通知定义 /// public class NotificationDefinition { /// /// 通知名称 /// [NotNull] public string Name { get; set; } /// /// 通知显示名称 /// [NotNull] public ILocalizableString DisplayName { get => _displayName; set => _displayName = Check.NotNull(value, nameof(value)); } private ILocalizableString _displayName; /// /// 通知说明 /// [CanBeNull] public ILocalizableString Description { get; set; } /// /// 允许客户端显示订阅 /// public bool AllowSubscriptionToClients { get; set; } /// /// 存活类型 /// public NotificationLifetime NotificationLifetime { get; set; } /// /// 通知类型 /// public NotificationType NotificationType { get; set; } /// /// 通知提供者 /// public List Providers { get; } /// /// 额外属性 /// [NotNull] public Dictionary Properties { get; } public NotificationDefinition( string name, ILocalizableString displayName = null, ILocalizableString description = null, NotificationType notificationType = NotificationType.Application, NotificationLifetime lifetime = NotificationLifetime.Persistent, bool allowSubscriptionToClients = false) { Name = name; DisplayName = displayName ?? new FixedLocalizableString(name); Description = description; NotificationLifetime = lifetime; NotificationType = notificationType; AllowSubscriptionToClients = allowSubscriptionToClients; Providers = new List(); Properties = new Dictionary(); } public virtual NotificationDefinition WithProviders(params string[] providers) { if (!providers.IsNullOrEmpty()) { Providers.AddRange(providers); } return this; } public virtual NotificationDefinition WithProperty(string key, object value) { Properties[key] = value; return this; } public override string ToString() { return $"[{nameof(NotificationDefinition)} {Name}]"; } }