Class ArgumentCollection
Collection of arguments. Two common use cases: 1) create a collection of arguments in order to describe what arguments are available for a command and 2) to represent the arguments on a command with the values populated from the command line.
Inherited Members
Namespace: Benday.CommandsFramework
Assembly: Benday.CommandsFramework.dll
Syntax
public class ArgumentCollection : IEnumerable<IArgument>, IEnumerable
Constructors
| Edit this page View SourceArgumentCollection()
Constructor. Creates an empty argument collection.
Declaration
public ArgumentCollection()
ArgumentCollection(Dictionary<string, IArgument>)
Constructor. Creates the argument collection and populates it with arguments in the supplied dictionary.
Declaration
public ArgumentCollection(Dictionary<string, IArgument> fromDictionary)
Parameters
Type | Name | Description |
---|---|---|
Dictionary<string, IArgument> | fromDictionary | Dictionary of keys and values that will be used to populate this argument collection |
Exceptions
Type | Condition |
---|---|
Invalid |
ArgumentCollection(Dictionary<string, string>)
Constructor. Creates the argument collection and populates it with string arguments and values from the supplied dictionary.
Declaration
public ArgumentCollection(Dictionary<string, string> fromDictionary)
Parameters
Type | Name | Description |
---|---|---|
Dictionary<string, string> | fromDictionary | Dictionary of keys and values that will be used to populate this argument collection |
Exceptions
Type | Condition |
---|---|
Argument |
|
Invalid |
Properties
| Edit this page View SourceCount
Number of arguments in this collection
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
int |
this[string]
Indexer. Get the argument by argument name
Declaration
public IArgument this[string key] { get; }
Parameters
Type | Name | Description |
---|---|---|
string | key | Name of the argument |
Property Value
Type | Description |
---|---|
IArgument | Returns the argument if it exists |
Keys
Collection of argument keys/names managed
Declaration
public Dictionary<string, IArgument>.KeyCollection Keys { get; }
Property Value
Type | Description |
---|---|
Dictionary<string, IArgument>.Key |
Methods
| Edit this page View SourceAdd(string, IArgument)
Add an argument to the collection
Declaration
public void Add(string key, IArgument value)
Parameters
| Edit this page View SourceAdd(string, string)
Add a string argument and value
Declaration
public void Add(string key, string value)
Parameters
| Edit this page View SourceContainsKey(string)
Does this collection have an argument with this name/key?
Declaration
public bool ContainsKey(string key)
Parameters
Type | Name | Description |
---|---|---|
string | key | Name of the argument |
Returns
Type | Description |
---|---|
bool | True if it exists in this collection |
GetEnumerator()
Enumerator
Declaration
public IEnumerator<IArgument> GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator<IArgument> | Enumerator for the arguments in this collection |
Remove(string)
Remove an argument
Declaration
public void Remove(string key)
Parameters
Type | Name | Description |
---|---|---|
string | key | Name of the argument to remove |
SetValues(Dictionary<string, string>)
For an argument collection that already has arguments defined, populate those argument definitions with values. This is typically the arguments from the command line.
Declaration
public void SetValues(Dictionary<string, string> fromArguments)
Parameters
Type | Name | Description |
---|---|---|
Dictionary<string, string> | fromArguments | Key value pairs to set in to this collection |
Exceptions
Type | Condition |
---|---|
Argument |