Arguments Class

Represents an ordered set of arguments along with optional arguments parsed from a command-line.

Definition

Namespace: Gemstone.Console
Assembly: Gemstone.Common (in Gemstone.Common.dll) Version: 1.0.128 -- Release Build+d050cfc5563c89a1188cc3c6b2d417530856f490
[SerializableAttribute]
public class Arguments : IEnumerable<KeyValuePair<string, string>>, 
	IEnumerable, ISerializable
Inheritance
Object    Arguments
Implements
IEnumerableKeyValuePairString, String, IEnumerable, ISerializable

Example

This example shows how to parse a command-line command that does not contain an executable name:
C#
using System;
using GSF;
using GSF.Console;

class Program
{
    static void Main()
    {
        Arguments args = new Arguments("Sample.txt -wrap=true");
        string file = args["OrderedArg1"];
        bool wrapText = args["wrap"].ParseBoolean();

        Console.WriteLine(string.Format("File: {0}", file));
        Console.WriteLine(string.Format("Wrap text: {0}", wrapText));
        Console.ReadLine();
    }
}
This example shows how to parse a command-line command that contains an executable name in it:
C#
using System;
using GSF.Console;

class Program
{
    static void Main()
    {
        // Environment.CommandLine = @"""c:\program files\tva\theme application\app.exe"" Document1.dcx -theme=default"
        Arguments args = new Arguments(Environment.CommandLine, true);
        string doc = args["OrderedArg1"];
        string theme = args["theme"];

        Console.WriteLine(string.Format("Document: {0}", doc));
        Console.WriteLine(string.Format("Application theme: {0}", theme));
        Console.ReadLine();
    }
}

Constructors

Arguments(String) Initializes a new instance of the Arguments class.
Arguments(SerializationInfo, StreamingContext) Creates a new Arguments from serialization parameters.
Arguments(String, Boolean) Initializes a new instance of the Arguments class.
Arguments(String, String) Initializes a new instance of the Arguments class.
Arguments(String, String, Boolean) Initializes a new instance of the Arguments class.

Properties

ContainsHelpRequest Gets a boolean value that indicates whether the command-line command contains request for displaying help.
Count Gets the total number of arguments (ordered and optional) present in the command-line command.
InternalDictionary Gets the dictionary containing all of the arguments present in the command-line command.
Item Gets the value for the specified argument from the command-line command.
OrderedArgCount Gets the total number of ordered arguments in the command-line command.
OrderedArgID Gets the prefix text in the identifier of ordered arguments present in the command-line command.
OrderedArgs Gets the ordered arguments as an array of strings.

Methods

EqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
Escape Escapes a string so that it will be parsed as a single argument by the ToArgs(String) method.
Exists Gets a boolean value that indicates whether the specified argument is present in the command-line command.
FinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object)
GetEnumerator Returns an IEnumerator for iterating through all the command-line command arguments.
GetHashCodeServes as the default hash function.
(Inherited from Object)
GetObjectData Populates a SerializationInfo with the data needed to serialize the target object.
GetTypeGets the Type of the current instance.
(Inherited from Object)
MemberwiseCloneCreates a shallow copy of the current Object.
(Inherited from Object)
ParseCommand This function can be used to parse a single parameterized string and turn it into an array of parameters.
ToArgs Provides an array of arguments parsed from the given command using parsing rules similar to those used in POSIX environments.
ToString Gets a string representation of the Arguments object.
(Overrides ObjectToString)
TryGetValue Gets the value associated with the specified argument in the command-line command.

Fields

DefaultOrderedArgID Default value for OrderedArgID.
TokenRegex Regular expression pattern for tokenizing a list of arguments.

Extension Methods

AllParallelKeyValuePairString, String Determines whether all elements of a sequence satisfy a condition with each item being tested in parallel.
(Defined by CollectionExtensions)
DistinctByKeyValuePairString, String, TKey Returns only the elements whose keys are distinct.
(Defined by CollectionExtensions)
GetEnumValueOrDefault Gets the enumeration constant for value, if defined in the enumeration, or a default value.
(Defined by EnumExtensions)
GetEnumValueOrDefaultT Gets the enumeration constant for this value, if defined in the enumeration, or a default value.
(Defined by EnumExtensions)
MajorityKeyValuePairString, String Returns the majority value in the collection, or default type value if no item represents the majority.
(Defined by CollectionExtensions)
MajorityKeyValuePairString, String Returns the majority value in the collection, or defaultValue if no item represents the majority.
(Defined by CollectionExtensions)
MajorityByKeyValuePairString, String, TKey Returns the majority value in the collection, or default type value if no item represents the majority.
(Defined by CollectionExtensions)
MajorityByKeyValuePairString, String, TKey Returns the majority value in the collection, or defaultValue if no item represents the majority.
(Defined by CollectionExtensions)
MaxKeyValuePairString, StringReturns the largest item from the enumeration.
(Defined by CollectionExtensions)
MaxKeyValuePairString, StringReturns the largest item from the enumeration.
(Defined by CollectionExtensions)
MaxByKeyValuePairString, String, TKeySelects the largest item from the enumeration.
(Defined by CollectionExtensions)
MedianKeyValuePairString, String Gets the median item(s) from an enumeration, i.e., one return item for odd lengths, two for even lengths.
(Defined by CollectionExtensions)
MinKeyValuePairString, StringReturns the smallest item from the enumeration.
(Defined by CollectionExtensions)
MinKeyValuePairString, StringReturns the smallest item from the enumeration.
(Defined by CollectionExtensions)
MinByKeyValuePairString, String, TKeySelects the smallest item from the enumeration.
(Defined by CollectionExtensions)
MinorityKeyValuePairString, String Returns the minority value in the collection, or default type value if no item represents the minority.
(Defined by CollectionExtensions)
MinorityKeyValuePairString, String Returns the minority value in the collection, or defaultValue if no item represents the minority.
(Defined by CollectionExtensions)
MinorityByKeyValuePairString, String, TKey Returns the minority value in the collection, or default type value if no item represents the majority.
(Defined by CollectionExtensions)
MinorityByKeyValuePairString, String, TKey Returns the minority value in the collection, or defaultValue if no item represents the majority.
(Defined by CollectionExtensions)
ToDelimitedStringKeyValuePairString, StringConverts an enumeration to a string, using the default delimiter ("|") that can later be converted back to a list using LoadDelimitedString.
(Defined by CollectionExtensions)
ToDelimitedStringKeyValuePairString, StringConverts an enumeration to a string that can later be converted back to a list using LoadDelimitedString.
(Defined by CollectionExtensions)
ToDelimitedStringKeyValuePairString, StringConverts an enumeration to a string that can later be converted back to a list using LoadDelimitedString.
(Defined by CollectionExtensions)
ToPagedListKeyValuePairString, String Gets a PagedListT to paginate source enumeration for a given page and specified pageSize.
(Defined by CollectionExtensions)

See Also