forked from smartstore/SmartStoreNET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNotifier.cs
More file actions
53 lines (44 loc) · 1.36 KB
/
Copy pathNotifier.cs
File metadata and controls
53 lines (44 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SmartStore.Core.Localization;
namespace SmartStore.Core.Logging
{
public interface INotifier
{
void Add(NotifyType type, LocalizedString message, bool durable = true);
ICollection<NotifyEntry> Entries { get; }
}
public class Notifier : INotifier
{
private readonly HashSet<NotifyEntry> _entries = new HashSet<NotifyEntry>();
public void Add(NotifyType type, LocalizedString message, bool durable = true)
{
_entries.Add(new NotifyEntry { Type = type, Message = message, Durable = durable });
}
public ICollection<NotifyEntry> Entries
{
get { return _entries; }
}
}
public static class INotifierExtension
{
public static void Information(this INotifier notifier, LocalizedString message, bool durable = true)
{
notifier.Add(NotifyType.Info, message, durable);
}
public static void Success(this INotifier notifier, LocalizedString message, bool durable = true)
{
notifier.Add(NotifyType.Success, message, durable);
}
public static void Warning(this INotifier notifier, LocalizedString message, bool durable = true)
{
notifier.Add(NotifyType.Warning, message, durable);
}
public static void Error(this INotifier notifier, LocalizedString message, bool durable = true)
{
notifier.Add(NotifyType.Error, message, durable);
}
}
}