Note
If you specify an explicit separator for a multi-value argument, it will not be
possible to use the separator in the individual argument values. There is no way to
escape it.
public class MultiValueSeparatorAttribute : Attribute
Public Class MultiValueSeparatorAttribute
Inherits Attribute
Dim instance As MultiValueSeparatorAttribute
public ref class MultiValueSeparatorAttribute : public Attribute
Normally, you need to supply the argument multiple times to set multiple values, e.g. by using -Sample Value1 -Sample Value2. If you specify the MultiValueSeparatorAttribute attribute, it allows you to specify multiple values with a single argument by using a separator.
There are two ways you can use separators for multi-value arguments: a white-space separator, or an explicit separator string.
You enable the use of white-space separators with the MultiValueSeparatorAttribute constructor. A multi-value argument that allows white-space separators is able to consume multiple values from the command line that follow it. All values that follow the name, up until the next argument name, are considered values for this argument.
For example, if you use -Sample Value1 Value2 Value3, all three arguments after -Sample are taken as values. In this case, it's not possible to supply any positional arguments until another named argument has been supplied.
Using white-space separators will not work if the CommandLineParserAllowWhiteSpaceValueSeparator property is or if the argument is a multi-value switch argument.
Using the MultiValueSeparatorAttribute(String) constructor, you instead specify an explicit character sequence to be used as a separator. For example, if the separator is set to a comma, you can use -Sample Value1,Value2.
Even if the MultiValueSeparatorAttribute is specified it is still possible to use multiple arguments to specify multiple values. For example, using a comma as the separator, -Sample Value1,Value2 -Sample Value3 will mean the argument "Sample" has three values.
MultiValueSeparatorAttribute | Initializes a new instance of the MultiValueSeparatorAttribute class using white-space as the separator. |
MultiValueSeparatorAttribute(String) | Initializes a new instance of the MultiValueSeparatorAttribute class. |
Separator | Gets the separator for the values of a multi-value argument. |
TypeId | When implemented in a derived class, gets a unique identifier for this Attribute. (Inherited from Attribute) |
Equals | Returns a value that indicates whether this instance is equal to a specified object. (Inherited from Attribute) |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object) |
GetHashCode | Returns the hash code for this instance. (Inherited from Attribute) |
GetType | Gets the Type of the current instance. (Inherited from Object) |
IsDefaultAttribute | When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from Attribute) |
Match | When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from Attribute) |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object) |
ToString | Returns a string that represents the current object. (Inherited from Object) |