8 changed files with 98 additions and 10 deletions
@ -0,0 +1,35 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
|
||||
|
namespace LINGYUN.Abp.Notifications |
||||
|
{ |
||||
|
public class NotificationDataMappingDictionary : Dictionary<string, List<NotificationDataMappingDictionaryItem>> |
||||
|
{ |
||||
|
public void Mapping(string cateGory, string provider, Func<NotificationData, NotificationData> func) |
||||
|
{ |
||||
|
if (ContainsKey(cateGory)) |
||||
|
{ |
||||
|
this[cateGory] = new List<NotificationDataMappingDictionaryItem>(); |
||||
|
} |
||||
|
this[cateGory].Add(new NotificationDataMappingDictionaryItem(provider, func)); |
||||
|
} |
||||
|
|
||||
|
public void MappingAll(string provider, Func<NotificationData, NotificationData> func) |
||||
|
{ |
||||
|
foreach(var mapping in this) |
||||
|
{ |
||||
|
Mapping(mapping.Key, provider, func); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public NotificationDataMappingDictionaryItem GetMapItemOrNull(string cateGory, string provider) |
||||
|
{ |
||||
|
if (ContainsKey(cateGory)) |
||||
|
{ |
||||
|
return this[cateGory].FirstOrDefault(map => map.Provider.Equals(provider)); |
||||
|
} |
||||
|
return null; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,16 @@ |
|||||
|
using System; |
||||
|
|
||||
|
namespace LINGYUN.Abp.Notifications |
||||
|
{ |
||||
|
public class NotificationDataMappingDictionaryItem |
||||
|
{ |
||||
|
public string Provider { get; } |
||||
|
|
||||
|
public Func<NotificationData, NotificationData> MappingFunc { get; } |
||||
|
public NotificationDataMappingDictionaryItem(string prodiver, Func<NotificationData, NotificationData> func) |
||||
|
{ |
||||
|
Provider = prodiver; |
||||
|
MappingFunc = func; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue