This project is read-only.

Ordinal Parameters

Ordinal parameters can be defined at the command line without a parameter name switch.

Example

The following command class will be used to demonstrate the ordinal parameter feature.

    [Command("Test")]
    class TestCommand : InputCommand
    {
        [Parameter(ordinalPosition:1)]
        public string ParameterOne { get; set; }

        [Parameter]
        public string ParameterTwo { get; set; }

        [Parameter(ordinalPosition:2)]
        public string ParameterThree { get; set; }

        public override void Invoke(CommandInvocationContext context)
        {
            // do something
        }
    }


This command may be invoked by defining the parameter name switch and value for each parameter.

Test -parameterOne value1 -parameterTwo "this is another value" -parameterThree value3


The command can also be invoked to take advantage of the ordinal parameter feature

Test value1 value3 -parameterTwo value2


Test -parameterTwo value2 value1 value3


Test -value1 -parameterTwo value2 value3


see also Parameter Attribute

Last edited Apr 13, 2013 at 8:00 PM by jeffhewitt, version 3

Comments

No comments yet.