-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathICommandFactory.Defaults.cs
More file actions
52 lines (43 loc) · 1.37 KB
/
ICommandFactory.Defaults.cs
File metadata and controls
52 lines (43 loc) · 1.37 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
using System;
using ManagedCode.Communication.Helpers;
namespace ManagedCode.Communication.Commands;
public partial interface ICommandFactory<TSelf>
where TSelf : class, ICommandFactory<TSelf>
{
static virtual TSelf Create(string commandType)
{
if (string.IsNullOrWhiteSpace(commandType))
{
throw new ArgumentException("Command type must be provided.", nameof(commandType));
}
return TSelf.Create(GuidHelper.CreateVersion7(), commandType);
}
static virtual TSelf Create<TEnum>(TEnum commandType)
where TEnum : Enum
{
return TSelf.Create(GuidHelper.CreateVersion7(), commandType.ToString());
}
static virtual TSelf Create<TEnum>(Guid commandId, TEnum commandType)
where TEnum : Enum
{
return TSelf.Create(commandId, commandType.ToString());
}
static virtual TSelf From(string commandType)
{
return TSelf.Create(commandType);
}
static virtual TSelf From(Guid commandId, string commandType)
{
return TSelf.Create(commandId, commandType);
}
static virtual TSelf From<TEnum>(TEnum commandType)
where TEnum : Enum
{
return TSelf.Create(commandType);
}
static virtual TSelf From<TEnum>(Guid commandId, TEnum commandType)
where TEnum : Enum
{
return TSelf.Create(commandId, commandType);
}
}