-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathCommand.cs
More file actions
45 lines (37 loc) · 1.27 KB
/
Command.cs
File metadata and controls
45 lines (37 loc) · 1.27 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
// Copyright (c) TotalSoft.
// This source code is licensed under the MIT license.
using MediatR;
using System;
namespace NBB.Application.DataContracts
{
[Obsolete("Ensures NBB4 compatibility. Use IRequest instead.")]
public abstract class Command : IRequest
{
public CommandMetadata Metadata { get; }
protected Command(CommandMetadata metadata = null)
{
Metadata = metadata ?? CommandMetadata.Default();
}
}
[Obsolete("Ensures NBB4 compatibility. Use IRequest<TResponse> instead")]
public abstract class Command<TResponse> : IRequest<TResponse>
{
public CommandMetadata Metadata { get; }
protected Command(CommandMetadata metadata = null)
{
Metadata = metadata ?? CommandMetadata.Default();
}
}
[Obsolete("Ensures NBB4 compatibility")]
public class CommandMetadata
{
public Guid CommandId { get; }
public DateTime CreationDate { get; }
public CommandMetadata(Guid commandId, DateTime creationDate)
{
CommandId = commandId;
CreationDate = creationDate;
}
public static CommandMetadata Default() => new(Guid.NewGuid(), DateTime.UtcNow);
}
}