-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathSniffItem.cs
More file actions
109 lines (93 loc) · 2.22 KB
/
SniffItem.cs
File metadata and controls
109 lines (93 loc) · 2.22 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
using System;
using System.Collections.Generic;
using System.Text;
using Windows.UI;
using Waher.Events;
namespace Waher.Mock
{
/// <summary>
/// Sniff item type.
/// </summary>
public enum SniffItemType
{
/// <summary>
/// Data received.
/// </summary>
DataReceived,
/// <summary>
/// Data transmitted.
/// </summary>
DataTransmitted,
/// <summary>
/// Text received.
/// </summary>
TextReceived,
/// <summary>
/// Text transmitted.
/// </summary>
TextTransmitted,
/// <summary>
/// Information.
/// </summary>
Information,
/// <summary>
/// Warning.
/// </summary>
Warning,
/// <summary>
/// Error.
/// </summary>
Error,
/// <summary>
/// Exception.
/// </summary>
Exception
}
/// <summary>
/// Represents one item in a sniffer output.
/// </summary>
public class SniffItem : ColorableItem
{
private readonly SniffItemType type;
private readonly DateTime timestamp;
private readonly string message;
private readonly byte[] data;
/// <summary>
/// Represents one item in a sniffer output.
/// </summary>
/// <param name="Timestamp">Timestamp of event.</param>
/// <param name="Type">Type of sniff record.</param>
/// <param name="Message">Message</param>
/// <param name="Data">Optional binary data.</param>
/// <param name="ForegroundColor">Foreground Color</param>
/// <param name="BackgroundColor">Background Color</param>
public SniffItem(DateTime Timestamp, SniffItemType Type, string Message, byte[] Data, Color ForegroundColor, Color BackgroundColor)
: base(ForegroundColor, BackgroundColor)
{
this.type = Type;
this.timestamp = Timestamp;
this.message = Message;
this.data = Data;
}
/// <summary>
/// Timestamp of event.
/// </summary>
public DateTime Timestamp => this.timestamp;
/// <summary>
/// Sniff item type.
/// </summary>
public SniffItemType Type => this.type;
/// <summary>
/// Time of day of event, as a string.
/// </summary>
public string Time { get { return this.timestamp.ToString("T"); } }
/// <summary>
/// Message
/// </summary>
public string Message => this.message;
/// <summary>
/// Optional binary data.
/// </summary>
public byte[] Data => this.data;
}
}