You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2.5 KiB
2.5 KiB
LINGYUN.Abp.Notifications.Common
通知系统的公共模块,提供了通知系统的基础定义和共享功能。
功能特性
- 通知定义
- 通知组定义
- 通知类型定义
- 通知级别定义
- 通用工具类
- 通知数据处理
- 通知状态管理
- 扩展功能
- 通知数据扩展
- 通知提供者扩展
模块引用
[DependsOn(typeof(AbpNotificationsCommonModule))]
public class YouProjectModule : AbpModule
{
// other
}
基础定义
通知组
public class NotificationGroupDefinition
{
public string Name { get; }
public string DisplayName { get; }
public string Description { get; }
public bool AllowSubscriptionToClients { get; }
}
通知定义
public class NotificationDefinition
{
public string Name { get; }
public string DisplayName { get; }
public string Description { get; }
public NotificationType NotificationType { get; }
public NotificationLifetime Lifetime { get; }
public bool AllowSubscriptionToClients { get; }
}
基本用法
- 定义通知组
public class YourNotificationGroupDefinitionProvider : NotificationGroupDefinitionProvider
{
public override void Define(INotificationGroupDefinitionContext context)
{
context.Add(
new NotificationGroupDefinition(
name: "App.Notifications",
displayName: L("AppNotifications"),
description: L("AppNotificationsDescription")
)
);
}
}
- 定义通知
public class YourNotificationDefinitionProvider : NotificationDefinitionProvider
{
public override void Define(INotificationDefinitionContext context)
{
context.Add(
new NotificationDefinition(
name: "App.NewMessage",
displayName: L("NewMessage"),
description: L("NewMessageDescription"),
notificationType: NotificationType.Application,
lifetime: NotificationLifetime.Persistent
)
);
}
}
- 使用通知数据扩展
public static class NotificationDataExtensions
{
public static void SetTitle(this NotificationData data, string title)
{
data.ExtraProperties["Title"] = title;
}
public static string GetTitle(this NotificationData data)
{
return data.ExtraProperties.GetOrDefault("Title") as string;
}
}