Show / Hide Table of Contents

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.

Inheritance
object
ArgumentCollection
Implements
IEnumerable<IArgument>
IEnumerable
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Benday.CommandsFramework
Assembly: Benday.CommandsFramework.dll
Syntax
public class ArgumentCollection : IEnumerable<IArgument>, IEnumerable

Constructors

| Edit this page View Source

ArgumentCollection()

Constructor. Creates an empty argument collection.

Declaration
public ArgumentCollection()
| Edit this page View Source

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
InvalidOperationException
| Edit this page View Source

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
ArgumentNullException
InvalidOperationException

Properties

| Edit this page View Source

Count

Number of arguments in this collection

Declaration
public int Count { get; }
Property Value
Type Description
int
| Edit this page View Source

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

| Edit this page View Source

Keys

Collection of argument keys/names managed

Declaration
public Dictionary<string, IArgument>.KeyCollection Keys { get; }
Property Value
Type Description
Dictionary<string, IArgument>.KeyCollection

Methods

| Edit this page View Source

Add(string, IArgument)

Add an argument to the collection

Declaration
public void Add(string key, IArgument value)
Parameters
Type Name Description
string key

Name of the argument

IArgument value

The populated argument to add

| Edit this page View Source

Add(string, string)

Add a string argument and value

Declaration
public void Add(string key, string value)
Parameters
Type Name Description
string key

Name of the argument

string value

Value for the argument

| Edit this page View Source

ContainsKey(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

| Edit this page View Source

GetEnumerator()

Enumerator

Declaration
public IEnumerator<IArgument> GetEnumerator()
Returns
Type Description
IEnumerator<IArgument>

Enumerator for the arguments in this collection

| Edit this page View Source

Remove(string)

Remove an argument

Declaration
public void Remove(string key)
Parameters
Type Name Description
string key

Name of the argument to remove

| Edit this page View Source

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
ArgumentNullException

Implements

IEnumerable<T>
IEnumerable

Extension Methods

ExtensionMethods.AddBoolean(ArgumentCollection, string)
ExtensionMethods.AddDateTime(ArgumentCollection, string)
ExtensionMethods.AddDirectory(ArgumentCollection, string)
ExtensionMethods.AddFile(ArgumentCollection, string)
ExtensionMethods.AddInt32(ArgumentCollection, string)
ExtensionMethods.AddString(ArgumentCollection, string)
ExtensionMethods.GetBooleanValue(ArgumentCollection, string)
ExtensionMethods.GetDateTimeValue(ArgumentCollection, string)
ExtensionMethods.GetInt32Value(ArgumentCollection, string)
ExtensionMethods.GetPathToDirectory(ArgumentCollection, string, bool)
ExtensionMethods.GetPathToFile(ArgumentCollection, string, bool)
ExtensionMethods.GetStringValue(ArgumentCollection, string)
ExtensionMethods.HasValue(ArgumentCollection, string)
  • Edit this page
  • View Source
In this article
Back to top Copyright © www.benday.com | info@benday.com