-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathIObserver.cs
More file actions
65 lines (61 loc) · 2.66 KB
/
IObserver.cs
File metadata and controls
65 lines (61 loc) · 2.66 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
54
55
56
57
58
59
60
61
62
63
64
65
// =================================================================================================================================
// Copyright (c) RapidField LLC. Licensed under the MIT License. See LICENSE.txt in the project root for license information.
// =================================================================================================================================
using System;
using System.Threading.Tasks;
namespace RapidField.SolidInstruments.EventAuthoring
{
/// <summary>
/// Represents an object that responds to events raised by one or more <see cref="IObservationSubject" /> instances.
/// </summary>
/// <remarks>
/// <see cref="IObservationSubject" /> and <see cref="IObserver" /> can be used to implement the observer pattern.
/// </remarks>
public interface IObserver
{
/// <summary>
/// Asynchronously notifies the current <see cref="IObserver" /> about the specified event.
/// </summary>
/// <typeparam name="TSubject">
/// The type of the observation subject.
/// </typeparam>
/// <typeparam name="TEvent">
/// The type of the event that is raised.
/// </typeparam>
/// <param name="subject">
/// The observation subject.
/// </param>
/// <param name="observation">
/// The event that was raised.
/// </param>
/// <returns>
/// A task representing the asynchronous operation.
/// </returns>
/// <exception cref="ArgumentNullException">
/// <paramref name="subject" /> is <see langword="null" /> -or- <paramref name="observation" /> is <see langword="null" />.
/// </exception>
public Task NotifyAsync<TSubject, TEvent>(TSubject subject, TEvent observation)
where TSubject : IObservationSubject
where TEvent : IEvent;
/// <summary>
/// Adds the current <see cref="IObserver" /> to the specified subject's list of event notification targets.
/// </summary>
/// <param name="subject">
/// The subject to begin observing.
/// </param>
/// <exception cref="ArgumentNullException">
/// <paramref name="subject" /> is <see langword="null" />.
/// </exception>
/// <exception cref="ObjectDisposedException">
/// <paramref name="subject" /> is disposed.
/// </exception>
public void Observe(IObservationSubject subject);
/// <summary>
/// Gets a textual value that uniquely identifies the current <see cref="IObserver" />.
/// </summary>
public String ObserverIdentity
{
get;
}
}
}