markus / ConvertService / ServiceController / Markus.Mvvm.ToolKit / RelayCommand / EventRaiser.cs @ 5c387707
이력 | 보기 | 이력해설 | 다운로드 (1.04 KB)
1 | 5c387707 | semi | using System; |
---|---|---|---|
2 | using System.Collections.Generic; |
||
3 | using System.Linq; |
||
4 | using System.Text; |
||
5 | using System.Threading.Tasks; |
||
6 | |||
7 | namespace Markus.Mvvm.ToolKit |
||
8 | { |
||
9 | public static class EventRaiser |
||
10 | { |
||
11 | public static void Raise(this EventHandler handler, object sender) |
||
12 | { |
||
13 | handler?.Invoke(sender, EventArgs.Empty); |
||
14 | } |
||
15 | |||
16 | public static void Raise<T>(this EventHandler<EventArgs<T>> handler, object sender, T value) |
||
17 | { |
||
18 | handler?.Invoke(sender, new EventArgs<T>(value)); |
||
19 | } |
||
20 | |||
21 | public static void Raise<T>(this EventHandler<T> handler, object sender, T value) where T : EventArgs |
||
22 | { |
||
23 | handler?.Invoke(sender, value); |
||
24 | } |
||
25 | |||
26 | public static void Raise<T>(this EventHandler<EventArgs<T>> handler, object sender, EventArgs<T> value) |
||
27 | { |
||
28 | handler?.Invoke(sender, value); |
||
29 | } |
||
30 | } |
||
31 | |||
32 | public class EventArgs<T> : EventArgs |
||
33 | { |
||
34 | public EventArgs(T value) |
||
35 | { |
||
36 | Value = value; |
||
37 | } |
||
38 | |||
39 | public T Value { get; private set; } |
||
40 | } |
||
41 | } |