Mono.Options.OptionSet.Parse Method
Parses argument and invokes Option.Invoke(OptionContext) if appropriate.

Syntax

protected virtual bool Parse (string argument, OptionContext c)

See Also

OptionSet.CreateOptionContext
OptionSet.Parse(IEnumerable<string>)

Parameters

argument
A string containing the current option to parse.
c
A Mono.Options.OptionContext containing the current parser context.

Returns

A bool specifying whether or not argument was handled. If false, then OptionSet.Parse(IEnumerable<string>) will return argument as an unhandled option.

Remarks

This method is called for each string within the IEnumerable<string> provided to OptionSet.Parse(IEnumerable<string>), which thus gives this method a chance to parse a single option, or chain together multiple options to form a single option (as is necessary when an option and its value are separated, e.g. with -option value).

Operation

The default implementation will check OptionContext.Option, which is assumed to be a Mono.Options.Option in need of a value. If OptionContext.Option is non-null, then argument is OptionValueCollection.Add(string)ed to OptionContext.OptionValues and Option.Invoke(OptionContext) is invoked.

Next, OptionSet.GetOptionParts(string, String@, String@, String@, String@) is invoked. If GetOptionParts returns false, then false is returned from Parse.

Finally, check to see if the name returned from GetOptionParts is registered; if it is, handle it appropriately. If it isn't, check to see if name is a bundled option or a boolean option. If name isn't any registered option, then false is returned. Otherwise, true is returned.

Note to Inheritors

Inheriting types can override this method if they want to customize the per-option parsing within the containing OptionSet.Parse(IEnumerable<string>) invocation.

Inheriting types should consider overriding OptionSet.CreateOptionContext if they want to store extra information for use and retrieval during each Parse invocation.

Requirements

Namespace: Mono.Options
Assembly: Mono.Options (in Mono.Options.dll)
Assembly Versions: 0.2.0.0, 0.2.1.0, 0.2.2.0, 0.2.3.0