-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIEventFor.cs
More file actions
93 lines (91 loc) · 3.23 KB
/
IEventFor.cs
File metadata and controls
93 lines (91 loc) · 3.23 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
using System.Collections.Generic;
namespace Inversion.Process {
/// <summary>
/// Represents an event occuring in the system.
/// </summary>
/// <typeparam name="TState">The type of context state.</typeparam>
public interface IEventFor<TState>: IData, IEnumerable<KeyValuePair<string, string>> {
/// <summary>
/// Provides indexed access to the events parameters.
/// </summary>
/// <param name="key">The key of the parameter to look up.</param>
/// <returns>Returns the parameter indexed by the key.</returns>
string this[string key] { get; }
/// <summary>
/// The simple message the event represents.
/// </summary>
/// <remarks>
/// Again, exactly what this means is application specific.
/// </remarks>
string Message { get; }
/// <summary>
/// The parameters for this event represented
/// as key-value pairs.
/// </summary>
IDictionary<string, string> Params { get; }
/// <summary>
/// Adds a key-value pair as a parameter to the event.
/// </summary>
/// <param name="key">The key of the parameter.</param>
/// <param name="value">The value of the parameter.</param>
void Add(string key, string value);
/// <summary>
/// The context upon which this event is being fired.
/// </summary>
/// <remarks>
/// And event always belongs to a context.
/// </remarks>
IContextFor<TState> Context { get; }
/// <summary>
/// Any object that the event may be carrying.
/// </summary>
/// <remarks>
/// This is a dirty escape hatch, and
/// can even be used as a "return" value
/// for the event.
/// </remarks>
IData Object { get; set; }
/// <summary>
/// Determines whether or not the parameters
/// specified exist in the event.
/// </summary>
/// <param name="parms">The parameters to check for.</param>
/// <returns>Returns true if all the parameters exist; otherwise return false.</returns>
bool HasParams(params string[] parms);
/// <summary>
/// Determines whether or not the parameters
/// specified exist in the event.
/// </summary>
/// <param name="parms">The parameters to check for.</param>
/// <returns>Returns true if all the parameters exist; otherwise return false.</returns>
bool HasParams(IEnumerable<string> parms);
/// <summary>
/// Determines whether or not all the key-value pairs
/// provided exist in the events parameters.
/// </summary>
/// <param name="match">The key-value pairs to check for.</param>
/// <returns>
/// Returns true if all the key-value pairs specified exists in the events
/// parameters; otherwise returns false.
/// </returns>
bool HasParamValues(IEnumerable<KeyValuePair<string, string>> match);
/// <summary>
/// Determines whether or not each of the prameters specified
/// exist on the event, and creates an error for each one that
/// does not.
/// </summary>
/// <param name="parms">The paramter names to check for.</param>
/// <returns>
/// Returns true if each of the parameters exist on the event;
/// otherwise returns false.
/// </returns>
bool HasRequiredParams(params string[] parms);
/// <summary>
/// Fires the event on the context to which it is bound.
/// </summary>
/// <returns>
/// Returns the event that has just been fired.
/// </returns>
IEventFor<TState> Fire();
}
}