-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTextualCommand.cs
More file actions
96 lines (89 loc) · 3.32 KB
/
TextualCommand.cs
File metadata and controls
96 lines (89 loc) · 3.32 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
// =================================================================================================================================
// Copyright (c) RapidField LLC. Licensed under the MIT License. See LICENSE.txt in the project root for license information.
// =================================================================================================================================
using RapidField.SolidInstruments.Core.ArgumentValidation;
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
namespace RapidField.SolidInstruments.Command
{
/// <summary>
/// Represents a command that is described by textual information.
/// </summary>
/// <remarks>
/// <see cref="TextualCommand" /> is the default implementation of <see cref="ITextualCommand" />.
/// </remarks>
[DataContract]
public sealed class TextualCommand : Command, ITextualCommand
{
/// <summary>
/// Initializes a new instance of the <see cref="TextualCommand" /> class.
/// </summary>
public TextualCommand()
: this(String.Empty)
{
return;
}
/// <summary>
/// Initializes a new instance of the <see cref="TextualCommand" /> class.
/// </summary>
/// <param name="value">
/// The textual command value.
/// </param>
/// <exception cref="ArgumentNullException">
/// <paramref name="value" /> is <see langword="null" />.
/// </exception>
public TextualCommand(String value)
: this(value, Array.Empty<String>())
{
return;
}
/// <summary>
/// Initializes a new instance of the <see cref="TextualCommand" /> class.
/// </summary>
/// <param name="value">
/// The textual command value.
/// </param>
/// <param name="labels">
/// A collection of textual labels that provide categorical and/or contextual information about the command.
/// </param>
/// <exception cref="ArgumentNullException">
/// <paramref name="value" /> is <see langword="null" /> -or- <paramref name="labels" /> is <see langword="null" />.
/// </exception>
public TextualCommand(String value, IEnumerable<String> labels)
: base()
{
Labels = new List<String>((labels.RejectIf().IsNull(nameof(labels)).TargetArgument));
Metadata = new Dictionary<String, String>();
Value = value.RejectIf().IsNull(nameof(value));
}
/// <summary>
/// Gets or sets a collection of textual labels that provide categorical and/or contextual information about the current
/// <see cref="TextualCommand" />.
/// </summary>
[DataMember]
public ICollection<String> Labels
{
get;
set;
}
/// <summary>
/// Gets or sets a dictionary of metadata for the current <see cref="TextualCommand" />.
/// </summary>
[DataMember]
public IDictionary<String, String> Metadata
{
get;
set;
}
/// <summary>
/// Gets or sets the textual command value.
/// </summary>
[DataMember]
public String Value
{
get;
set;
}
}
}