Switch Attribute

The Switch attribute may be used to decorate a command's property to define a command switch.

public Switch(string name = null)

The Switch attribute exposes a single properties, which is not required.
  • Name - the name of the switch (what must be entered into the HostInterface to define the switch on the command line - if this property is not set, the name of the decorated property will be used

A property with the switch attribute, must be of type SwitchParameter

    public class SwitchParameter
    {
        public bool IsPresent { get; set; }
    }

If the switch is present when the command is invoked, the IsPresent property of the switch parameter will be true, otherwise false.

Last edited Jun 15, 2013 at 8:24 PM by jeffhewitt, version 2

Comments

No comments yet.