-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDataCollectionEx.cs
35 lines (31 loc) · 1.34 KB
/
DataCollectionEx.cs
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
using Inversion.Collections;
namespace Inversion.Process {
/// <summary>
/// Extension methods acting upon `IDataCollection{ErrorMessage}` objects.
/// </summary>
public static class DataCollectionEx {
/// <summary>
/// Creates a new error message and adds it to the collection.
/// </summary>
/// <param name="self">The collection to add the message to.</param>
/// <param name="message">The human readable error message.</param>
/// <returns>Returns the error message object that was created.</returns>
public static ErrorMessage CreateMessage(this IDataCollection<ErrorMessage> self, string message) {
ErrorMessage msg = new ErrorMessage(message);
self.Add(msg);
return msg;
}
/// <summary>
/// Creates a new error message and adds it to the collection.
/// </summary>
/// <param name="self">The collection to add the message to.</param>
/// <param name="message">The human readable error message as text for string formatting.</param>
/// <param name="parms">Paramters for formatting the message text.</param>
/// <returns>Returns the error message object that was created.</returns>
public static ErrorMessage CreateMessage(this IDataCollection<ErrorMessage> self, string message, params object[] parms) {
ErrorMessage msg = new ErrorMessage(string.Format(message, parms));
self.Add(msg);
return msg;
}
}
}