|
1 | 1 | //Author MikeNakis (michael.gr)
|
2 |
| -namespace MikeNakis.InterfaceEvents |
| 2 | + |
| 3 | +namespace MikeNakis.Intertwine.InterfaceEvents |
3 | 4 | {
|
4 |
| - /// <summary> |
5 |
| - /// Defines the operations that can be performed on the source of an interface-event. |
6 |
| - /// </summary> |
7 |
| - /// <typeparam name="I">The type of interface of the event.</typeparam> |
8 |
| - public interface IInterfaceEventSource<I> |
9 |
| - where I: class //actually, interface. |
10 |
| - { |
11 |
| - /// <summary> |
12 |
| - /// Registers or deregisters an observer. |
13 |
| - /// </summary> |
14 |
| - /// <param name="register">Indicates whether the observer should be registered or deregistered.</param> |
15 |
| - /// <param name="observer">The observer to register or deregister.</param> |
16 |
| - void RegisterObserver( bool register, I observer ); |
| 5 | + /// <summary> |
| 6 | + /// Defines the operations that can be performed on the source of an interface-event. |
| 7 | + /// </summary> |
| 8 | + /// <typeparam name="I">The type of interface of the event.</typeparam> |
| 9 | + public interface IInterfaceEventSource<in I> where I : class //actually, interface. |
| 10 | + { |
| 11 | + /// <summary> |
| 12 | + /// Registers or unregisters an observer. |
| 13 | + /// </summary> |
| 14 | + /// <param name="register">Indicates whether the observer should be registered or unregistered.</param> |
| 15 | + /// <param name="observer">The observer to register or unregister.</param> |
| 16 | + void RegisterObserver( bool register, I observer ); |
17 | 17 |
|
18 |
| - /// <summary> |
19 |
| - /// Checks whether an observer is registered. |
20 |
| - /// </summary> |
21 |
| - /// <param name="observer">The observer to check.</param> |
22 |
| - /// <returns>true if the observer is registered; false otherwise.</returns> |
23 |
| - bool IsObserverRegistered( I observer ); |
24 |
| - } |
| 18 | + /// <summary> |
| 19 | + /// Checks whether an observer is registered. |
| 20 | + /// </summary> |
| 21 | + /// <param name="observer">The observer to check.</param> |
| 22 | + /// <returns>true if the observer is registered; false otherwise.</returns> |
| 23 | + bool IsObserverRegistered( I observer ); |
| 24 | + } |
25 | 25 |
|
26 |
| - namespace Extensions |
27 |
| - { |
28 |
| - public static partial class Extensions |
29 |
| - { |
30 |
| - /// <summary> |
31 |
| - /// Registers an observer. |
32 |
| - /// </summary> |
33 |
| - /// <typeparam name="I">The type of interface of the event.</typeparam> |
34 |
| - /// <param name="source">The event-source with which to register the observer.</param> |
35 |
| - /// <param name="observer">The observer to register.</param> |
36 |
| - public static void RegisterObserver<I>( this IInterfaceEventSource<I> source, I observer ) |
37 |
| - where I: class //actually, interface. |
38 |
| - { |
39 |
| - source.RegisterObserver( true, observer ); |
40 |
| - } |
| 26 | + namespace Extensions |
| 27 | + { |
| 28 | + public static class InterfaceEventsExtensions |
| 29 | + { |
| 30 | + /// <summary> |
| 31 | + /// Registers an observer. |
| 32 | + /// </summary> |
| 33 | + /// <typeparam name="I">The type of interface of the event.</typeparam> |
| 34 | + /// <param name="source">The event-source with which to register the observer.</param> |
| 35 | + /// <param name="observer">The observer to register.</param> |
| 36 | + public static void RegisterObserver<I>( this IInterfaceEventSource<I> source, I observer ) where I : class //actually, interface. |
| 37 | + { |
| 38 | + source.RegisterObserver( true, observer ); |
| 39 | + } |
41 | 40 |
|
42 |
| - /// <summary> |
43 |
| - /// Deregisters an observer. |
44 |
| - /// </summary> |
45 |
| - /// <typeparam name="I">The type of interface of the event.</typeparam> |
46 |
| - /// <param name="source">The event-source with which the observer has been registered.</param> |
47 |
| - /// <param name="observer">The observer to deregister.</param> |
48 |
| - public static void DeregisterObserver<I>( this IInterfaceEventSource<I> source, I observer ) |
49 |
| - where I: class //actually, interface. |
50 |
| - { |
51 |
| - source.RegisterObserver( false, observer ); |
52 |
| - } |
53 |
| - } |
54 |
| - } |
| 41 | + /// <summary> |
| 42 | + /// Unregisters an observer. |
| 43 | + /// </summary> |
| 44 | + /// <typeparam name="I">The type of interface of the event.</typeparam> |
| 45 | + /// <param name="source">The event-source with which the observer has been registered.</param> |
| 46 | + /// <param name="observer">The observer to unregister.</param> |
| 47 | + public static void UnregisterObserver<I>( this IInterfaceEventSource<I> source, I observer ) where I : class //actually, interface. |
| 48 | + { |
| 49 | + source.RegisterObserver( false, observer ); |
| 50 | + } |
| 51 | + } |
| 52 | + } |
55 | 53 | }
|
0 commit comments