-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMessage.cs
48 lines (42 loc) · 1.5 KB
/
Message.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
36
37
38
39
40
41
42
43
44
45
46
47
48
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
namespace MockServiceBus
{
public enum MessageState { Active, Ignored, Transfered };
[DebuggerDisplay("{State} {LastTraversedPath}")]
public class Message
{
public Message()
{
BrokeredProperties.Add("MessageId", Guid.NewGuid().ToString("N"));
State = MessageState.Active;
}
public List<string> TraversedPath { get; set; } = new List<string>();
public MessageState State { get; set; }
public Dictionary<string, object> BrokeredProperties { get; set; } = new Dictionary<string, object>();
public Dictionary<string, object> CustomProperties { get; set; } = new Dictionary<string, object>();
public string LastTraversedPath
{
get
{
return TraversedPath.Count == 0 ? "empty" : TraversedPath.Last();
}
}
public Message Copy()
{
var clone = new Message
{
BrokeredProperties = BrokeredProperties.ToDictionary(entry => entry.Key,
entry => entry.Value),
CustomProperties = CustomProperties.ToDictionary(entry => entry.Key,
entry => entry.Value),
State = State,
TraversedPath = TraversedPath.ToList()
};
return clone;
}
}
}