-
Notifications
You must be signed in to change notification settings - Fork 325
Expand file tree
/
Copy pathHistoryEvent.cs
More file actions
108 lines (95 loc) · 3.48 KB
/
HistoryEvent.cs
File metadata and controls
108 lines (95 loc) · 3.48 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
// ----------------------------------------------------------------------------------
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------
#nullable enable
namespace DurableTask.Core.History
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
/// <summary>
/// Base class for history events
/// </summary>
[DataContract]
[KnownType(nameof(KnownTypes))]
public abstract class HistoryEvent : IExtensibleDataObject
{
private static IReadOnlyCollection<Type>? knownTypes;
/// <summary>
/// List of all event classes, for use by the DataContractSerializer
/// </summary>
/// <returns>An enumerable of all known types that implement <see cref="HistoryEvent"/>.</returns>
public static IEnumerable<Type> KnownTypes()
{
if (knownTypes != null)
{
return knownTypes;
}
knownTypes = typeof(HistoryEvent).Assembly
.GetTypes()
.Where(x => !x.IsAbstract && typeof(HistoryEvent).IsAssignableFrom(x))
.ToList()
.AsReadOnly();
return knownTypes;
}
/// <summary>
/// Creates a new history event
/// </summary>
internal HistoryEvent()
{
Timestamp = DateTime.UtcNow;
}
/// <summary>
/// Creates a new history event with the supplied event id
/// </summary>
/// <param name="eventId">The integer event id</param>
protected HistoryEvent(int eventId)
{
EventId = eventId;
Timestamp = DateTime.UtcNow;
}
/// <summary>
/// Gets the event id
/// </summary>
[DataMember]
public int EventId { get; internal set; }
/// <summary>
/// Gets the IsPlayed status
/// </summary>
[DataMember]
public bool IsPlayed { get; set; }
/// <summary>
/// Gets the event timestamp
/// </summary>
[DataMember]
public DateTime Timestamp { get; set; }
/// <summary>
/// Gets the event type
/// </summary>
[DataMember]
public virtual EventType EventType { get; private set; }
/// <summary>
/// Implementation for <see cref="IExtensibleDataObject.ExtensionData"/>.
/// </summary>
public ExtensionDataObject? ExtensionData { get; set; }
/// <summary>
/// Gets or sets whether this is a poison message.
/// </summary>
public bool IsPoison { get; set; } = false;
/// <summary>
/// Gets or sets user-facing details for why a message was labeled as poison.
/// This is to be set by each storage provider.
/// </summary>
public string PoisonGuidance { get; set; } = "";
}
}