Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 192
DynamicOption PowerShell
Jianyun edited this page Feb 25, 2016
·
9 revisions
publicclassDynamicOption{publicOptionCategoryCategory{get;set;}publicOptionTypeExpectedType{get;set;}publicstringName{get;set;}publicboolIsRequired{get;set;}publicIEnumerable<string>PermittedValues{get;set;}}Dynamic Options are specified for a given category:
| Value | Purpose |
|---|---|
Category | The operation that the dynamic option is for (see [[OptionCategory enum |
Type | the data type for the option (see [[OptionType enum |
Name | the option name. This is exposed to the end user. |
IsRequired | indicates that this option is required for this operation. If not present, the host should not proceed. |
PermittedValues | a collection of possible values the user is permitted to specify. |
Thefollowing example shows how to define a dynamic option."-Destination"isrequired in Install-Package.publicvoid GetDynamicOptions(stringcategory,Requestrequest){if(request==null){thrownewArgumentNullException("request");}switch((category ??string.Empty).ToLowerInvariant()){case "install":
request.YieldDynamicOption("Destination", Constants.OptionType.Folder, true); break;case "package":// put any options used when searching for packagesrequest.YieldDynamicOption("FilterOnTag",Constants.OptionType.StringArray,false);break;default:
request.Warning(Resources.Messages.UnkownCategory,PackageProviderName,"GetDynamicOptions",category);break;}}For how to retrieve values of dynamic parameters, please refer to Remarks section.