forked from sbozzie/test-intel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIntelEventArgs.cs
More file actions
76 lines (69 loc) · 3.09 KB
/
Copy pathIntelEventArgs.cs
File metadata and controls
76 lines (69 loc) · 3.09 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
using System;
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Contracts;
using System.Globalization;
namespace PleaseIgnore.IntelMap {
/// <summary>Provides data for the intel reporting events.</summary>
/// <threadsafety static="true" instance="true" />
[Serializable]
public class IntelEventArgs : EventArgs {
/// <summary>
/// Initializes a new instance of <see cref="IntelEventArgs" /> class.
/// </summary>
/// <param name="channel">The base name of the <see cref="IntelChannel"/>
/// that initially reported this log entry.</param>
/// <param name="timestamp">The date and time this log entry was
/// generated.</param>
/// <param name="message">The content of the log entry.</param>
public IntelEventArgs(string channel, DateTime timestamp,
string message) {
Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(channel));
Contract.Requires<ArgumentException>(timestamp.Kind == DateTimeKind.Utc);
Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(message));
this.Channel = channel;
this.Timestamp = timestamp;
this.Message = message;
}
/// <summary>Gets the log file that generated this event.</summary>
/// <value>
/// The base name of the <see cref="IntelChannel"/> that reported this
/// log entry.
/// </value>
public string Channel { get; private set; }
/// <summary>Gets the timestamp of the log entry.</summary>
/// <value>
/// A value of <see cref="DateTime" /> that encodes the log entry's time
/// stamp in the UTC time zone.
/// </value>
public DateTime Timestamp { get; private set; }
/// <summary>Gets the content of the log entry.</summary>
/// <value>The payload of the log entry.</value>
public string Message { get; private set; }
/// <summary>
/// Returns a <see cref="System.String" /> that represents this
/// instance of <see cref="IntelChannel" />.
/// </summary>
/// <returns>
/// A <see cref="System.String" /> that represents this instance
/// of <see cref="IntelChannel" />.
/// </returns>
public override string ToString() {
return string.Format(
CultureInfo.CurrentCulture,
"{0}: [{1} - {2:u}] {3}",
GetType().Name,
this.Channel,
this.Timestamp,
this.Message);
}
/// <summary>Invariant method for Code Contracts.</summary>
[ContractInvariantMethod]
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic")]
private void ObjectInvariant() {
Contract.Invariant(!String.IsNullOrEmpty(this.Channel));
Contract.Invariant(Timestamp.Kind == DateTimeKind.Utc);
Contract.Invariant(!String.IsNullOrEmpty(this.Message));
}
}
}