C# Класс FastFind.ArgParser

A command line argument parsing class.
This class is based on the WordCount version from the Framework SDK samples. Any errors are mine.

There are two arrays of flags you'll pass to the constructors. The flagSymbols are supposed to be standalone switches that toggle an option on. The dataSymbols are for switches that take data values. For example, if your application needs a switch, -c, to set the count, you'd put "c" in the dataSymbols. This code will allow both "-c100" and the usual "-c" "100" both to be passed on the command line. Note that you can pass null/Nothing for dataSymbols if you don't need them.

Показать файл Открыть проект

Открытые методы

Метод Описание
OnUsage ( String errorInfo ) : void

Reports correct command line usage.

Parse ( String args ) : System.Boolean

Parses an arbitrary set of arguments.

Защищенные методы

Метод Описание
OnDoneParse ( ) : SwitchStatus

Called when parsing is finished so final sanity checking can be performed.

OnNonSwitch ( String value ) : SwitchStatus

Called when a non-switch value is parsed out.

OnSwitch ( String switchSymbol, String switchValue ) : SwitchStatus

Called when a switch is parsed out.

Every derived class must implement an OnSwitch method or a switch is considered an error.

Приватные методы

Метод Описание
ArgParser ( String flagSymbols, String dataSymbols, System.Boolean caseSensitiveSwitches ) : System
ArgParser ( String flagSymbols, String dataSymbols, System.Boolean caseSensitiveSwitches, String switchChars ) : System
IsSwitchInArray ( String switchArray, String value ) : Int32

Looks to see if the switch is in the array.

StartsWithSwitchChar ( String value ) : System.Boolean

Looks to see if this string starts with a switch character.

Описание методов

OnDoneParse() защищенный Метод

Called when parsing is finished so final sanity checking can be performed.
protected OnDoneParse ( ) : SwitchStatus
Результат SwitchStatus

OnNonSwitch() защищенный Метод

Called when a non-switch value is parsed out.
protected OnNonSwitch ( String value ) : SwitchStatus
value String /// The value parsed out. ///
Результат SwitchStatus

OnSwitch() защищенный Метод

Called when a switch is parsed out.
Every derived class must implement an OnSwitch method or a switch is considered an error.
protected OnSwitch ( String switchSymbol, String switchValue ) : SwitchStatus
switchSymbol String /// The switch value parsed out. ///
switchValue String /// The value of the switch. For flag switches this is null/Nothing. ///
Результат SwitchStatus

OnUsage() публичный абстрактный Метод

Reports correct command line usage.
public abstract OnUsage ( String errorInfo ) : void
errorInfo String /// The string with the invalid command line option. ///
Результат void

Parse() публичный Метод

Parses an arbitrary set of arguments.
/// Thrown if is null. ///
public Parse ( String args ) : System.Boolean
args String /// The string array to parse through. ///
Результат System.Boolean