protected object CreateVirtualMachineScaleSetVMListNextDynamicParameters() { dynamicParameters = new RuntimeDefinedParameterDictionary(); var pNextPageLink = new RuntimeDefinedParameter(); pNextPageLink.Name = "NextPageLink"; pNextPageLink.ParameterType = typeof(string); pNextPageLink.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByDynamicParameters", Position = 1, Mandatory = true }); pNextPageLink.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("NextPageLink", pNextPageLink); var pArgumentList = new RuntimeDefinedParameter(); pArgumentList.Name = "ArgumentList"; pArgumentList.ParameterType = typeof(object[]); pArgumentList.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByStaticParameters", Position = 2, Mandatory = true }); pArgumentList.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("ArgumentList", pArgumentList); return dynamicParameters; }
protected object CreateExtensionImageRegisterDynamicParameters() { dynamicParameters = new RuntimeDefinedParameterDictionary(); var pParameters = new RuntimeDefinedParameter(); pParameters.Name = "ExtensionImageRegisterParameters"; pParameters.ParameterType = typeof(Microsoft.WindowsAzure.Management.Compute.Models.ExtensionImageRegisterParameters); pParameters.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByDynamicParameters", Position = 1, Mandatory = true }); pParameters.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("ExtensionImageRegisterParameters", pParameters); var pArgumentList = new RuntimeDefinedParameter(); pArgumentList.Name = "ArgumentList"; pArgumentList.ParameterType = typeof(object[]); pArgumentList.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByStaticParameters", Position = 2, Mandatory = true }); pArgumentList.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("ArgumentList", pArgumentList); return dynamicParameters; }
protected object CreateHostedServiceListExtensionsDynamicParameters() { dynamicParameters = new RuntimeDefinedParameterDictionary(); var pServiceName = new RuntimeDefinedParameter(); pServiceName.Name = "ServiceName"; pServiceName.ParameterType = typeof(System.String); pServiceName.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByDynamicParameters", Position = 1, Mandatory = true }); pServiceName.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("ServiceName", pServiceName); var pArgumentList = new RuntimeDefinedParameter(); pArgumentList.Name = "ArgumentList"; pArgumentList.ParameterType = typeof(object[]); pArgumentList.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByStaticParameters", Position = 2, Mandatory = true }); pArgumentList.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("ArgumentList", pArgumentList); return dynamicParameters; }
protected object CreateVirtualMachineOSImageGetDetailsDynamicParameters() { dynamicParameters = new RuntimeDefinedParameterDictionary(); var pImageName = new RuntimeDefinedParameter(); pImageName.Name = "ImageName"; pImageName.ParameterType = typeof(System.String); pImageName.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByDynamicParameters", Position = 1, Mandatory = true }); pImageName.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("ImageName", pImageName); var pArgumentList = new RuntimeDefinedParameter(); pArgumentList.Name = "ArgumentList"; pArgumentList.ParameterType = typeof(object[]); pArgumentList.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByStaticParameters", Position = 2, Mandatory = true }); pArgumentList.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("ArgumentList", pArgumentList); return dynamicParameters; }
protected object CreateVirtualMachineScaleSetListDynamicParameters() { dynamicParameters = new RuntimeDefinedParameterDictionary(); var pResourceGroupName = new RuntimeDefinedParameter(); pResourceGroupName.Name = "ResourceGroupName"; pResourceGroupName.ParameterType = typeof(string); pResourceGroupName.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByDynamicParameters", Position = 1, Mandatory = true }); pResourceGroupName.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("ResourceGroupName", pResourceGroupName); var pArgumentList = new RuntimeDefinedParameter(); pArgumentList.Name = "ArgumentList"; pArgumentList.ParameterType = typeof(object[]); pArgumentList.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByStaticParameters", Position = 2, Mandatory = true }); pArgumentList.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("ArgumentList", pArgumentList); return dynamicParameters; }
protected override object NewDriveDynamicParameters() { try{ WriteVerbose("TmxProvider::NewDriveDynamicParameters()"); dynamicParameters = new RuntimeDefinedParameterDictionary(); var atts1 = new Collection<Attribute>(); var parameterAttribute1 = new ParameterAttribute {Mandatory = true}; //ParameterAttribute parameterAttribute1 = new ParameterAttribute(); //parameterAttribute1.Mandatory = true; //parameterAttribute2.ParameterSetName = "WindowNameParameterSet"; atts1.Add(parameterAttribute1); var attr1 = new AllowEmptyStringAttribute(); atts1.Add(attr1); dynamicParameters.Add( "windowName", new RuntimeDefinedParameter( "windowName", typeof(string), atts1)); var atts2 = new Collection<Attribute>(); var parameterAttribute2 = new ParameterAttribute {Mandatory = true}; //ParameterAttribute parameterAttribute2 = new ParameterAttribute(); //parameterAttribute2.Mandatory = true; //parameterAttribute2.ParameterSetName = "ProcessNameParameterSet"; atts2.Add(parameterAttribute2); var attr2 = new AllowEmptyStringAttribute(); atts2.Add(attr2); dynamicParameters.Add( "processName", new RuntimeDefinedParameter( "processName", typeof(string), atts2)); var atts3 = new Collection<Attribute>(); var parameterAttribute3 = new ParameterAttribute {Mandatory = true}; //ParameterAttribute parameterAttribute3 = new ParameterAttribute(); //parameterAttribute3.Mandatory = true; //parameterAttribute3.ParameterSetName = "ProcessIdParameterSet"; atts3.Add(parameterAttribute3); var attr3 = new AllowEmptyStringAttribute(); atts3.Add(attr3); dynamicParameters.Add( "processId", new RuntimeDefinedParameter( "processId", typeof(int), atts3)); return dynamicParameters; } catch (Exception e) { WriteVerbose(e.Message); WriteVerbose("TmxProvider::NewDriveDynamicParameters()"); return null; } }
protected object CreateVirtualMachineRestartDynamicParameters() { dynamicParameters = new RuntimeDefinedParameterDictionary(); var pServiceName = new RuntimeDefinedParameter(); pServiceName.Name = "ServiceName"; pServiceName.ParameterType = typeof(System.String); pServiceName.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByDynamicParameters", Position = 1, Mandatory = true }); pServiceName.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("ServiceName", pServiceName); var pDeploymentName = new RuntimeDefinedParameter(); pDeploymentName.Name = "DeploymentName"; pDeploymentName.ParameterType = typeof(System.String); pDeploymentName.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByDynamicParameters", Position = 2, Mandatory = true }); pDeploymentName.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("DeploymentName", pDeploymentName); var pVirtualMachineName = new RuntimeDefinedParameter(); pVirtualMachineName.Name = "VirtualMachineName"; pVirtualMachineName.ParameterType = typeof(System.String); pVirtualMachineName.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByDynamicParameters", Position = 3, Mandatory = true }); pVirtualMachineName.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("VirtualMachineName", pVirtualMachineName); var pArgumentList = new RuntimeDefinedParameter(); pArgumentList.Name = "ArgumentList"; pArgumentList.ParameterType = typeof(object[]); pArgumentList.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByStaticParameters", Position = 4, Mandatory = true }); pArgumentList.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("ArgumentList", pArgumentList); return dynamicParameters; }
protected object CreateExtensionImageUnregisterDynamicParameters() { dynamicParameters = new RuntimeDefinedParameterDictionary(); var pProviderNamespace = new RuntimeDefinedParameter(); pProviderNamespace.Name = "ProviderNamespace"; pProviderNamespace.ParameterType = typeof(System.String); pProviderNamespace.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByDynamicParameters", Position = 1, Mandatory = true }); pProviderNamespace.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("ProviderNamespace", pProviderNamespace); var pType = new RuntimeDefinedParameter(); pType.Name = "Type"; pType.ParameterType = typeof(System.String); pType.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByDynamicParameters", Position = 2, Mandatory = true }); pType.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("Type", pType); var pVersion = new RuntimeDefinedParameter(); pVersion.Name = "Version"; pVersion.ParameterType = typeof(System.String); pVersion.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByDynamicParameters", Position = 3, Mandatory = true }); pVersion.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("Version", pVersion); var pArgumentList = new RuntimeDefinedParameter(); pArgumentList.Name = "ArgumentList"; pArgumentList.ParameterType = typeof(object[]); pArgumentList.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByStaticParameters", Position = 4, Mandatory = true }); pArgumentList.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("ArgumentList", pArgumentList); return dynamicParameters; }
protected object CreateVirtualMachineStartRolesDynamicParameters() { dynamicParameters = new RuntimeDefinedParameterDictionary(); var pServiceName = new RuntimeDefinedParameter(); pServiceName.Name = "ServiceName"; pServiceName.ParameterType = typeof(System.String); pServiceName.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByDynamicParameters", Position = 1, Mandatory = true }); pServiceName.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("ServiceName", pServiceName); var pDeploymentName = new RuntimeDefinedParameter(); pDeploymentName.Name = "DeploymentName"; pDeploymentName.ParameterType = typeof(System.String); pDeploymentName.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByDynamicParameters", Position = 2, Mandatory = true }); pDeploymentName.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("DeploymentName", pDeploymentName); var pParameters = new RuntimeDefinedParameter(); pParameters.Name = "VirtualMachineStartRolesParameters"; pParameters.ParameterType = typeof(Microsoft.WindowsAzure.Management.Compute.Models.VirtualMachineStartRolesParameters); pParameters.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByDynamicParameters", Position = 3, Mandatory = true }); pParameters.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("VirtualMachineStartRolesParameters", pParameters); var pArgumentList = new RuntimeDefinedParameter(); pArgumentList.Name = "ArgumentList"; pArgumentList.ParameterType = typeof(object[]); pArgumentList.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByStaticParameters", Position = 4, Mandatory = true }); pArgumentList.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("ArgumentList", pArgumentList); return dynamicParameters; }
protected object CreateContainerServiceCreateOrUpdateDynamicParameters() { dynamicParameters = new RuntimeDefinedParameterDictionary(); var pResourceGroupName = new RuntimeDefinedParameter(); pResourceGroupName.Name = "ResourceGroupName"; pResourceGroupName.ParameterType = typeof(string); pResourceGroupName.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByDynamicParameters", Position = 1, Mandatory = true }); pResourceGroupName.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("ResourceGroupName", pResourceGroupName); var pContainerServiceName = new RuntimeDefinedParameter(); pContainerServiceName.Name = "Name"; pContainerServiceName.ParameterType = typeof(string); pContainerServiceName.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByDynamicParameters", Position = 2, Mandatory = true }); pContainerServiceName.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("Name", pContainerServiceName); var pParameters = new RuntimeDefinedParameter(); pParameters.Name = "ContainerService"; pParameters.ParameterType = typeof(ContainerService); pParameters.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByDynamicParameters", Position = 3, Mandatory = true }); pParameters.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("ContainerService", pParameters); var pArgumentList = new RuntimeDefinedParameter(); pArgumentList.Name = "ArgumentList"; pArgumentList.ParameterType = typeof(object[]); pArgumentList.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByStaticParameters", Position = 4, Mandatory = true }); pArgumentList.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("ArgumentList", pArgumentList); return dynamicParameters; }
public RuntimeDefinedParameterDictionary CreateForNewItem() { var parameters = new RuntimeDefinedParameterDictionary(); var attrs = from row in _columns let nullable = (bool)row["IS_NULLABLE"] let primaryKey = (bool)row["PRIMARY_KEY"] let columnName = row["COLUMN_NAME"].ToString() let dataType = ConvertSqliteTypeToType( row["DATA_TYPE"].ToString() ) select new RuntimeDefinedParameter( columnName, dataType, new Collection<Attribute> { new ParameterAttribute() { Mandatory = ! nullable && ! primaryKey, ValueFromPipelineByPropertyName = true, }, } ); attrs.ToList().ForEach(attr => parameters.Add(attr.Name, attr)); return parameters; }
protected object CreateVirtualMachineVMImageShareDynamicParameters() { dynamicParameters = new RuntimeDefinedParameterDictionary(); var pVMImageName = new RuntimeDefinedParameter(); pVMImageName.Name = "VMImageName"; pVMImageName.ParameterType = typeof(System.String); pVMImageName.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByDynamicParameters", Position = 1, Mandatory = true }); pVMImageName.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("VMImageName", pVMImageName); var pPermission = new RuntimeDefinedParameter(); pPermission.Name = "Permission"; pPermission.ParameterType = typeof(System.String); pPermission.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByDynamicParameters", Position = 2, Mandatory = true }); pPermission.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("Permission", pPermission); var pArgumentList = new RuntimeDefinedParameter(); pArgumentList.Name = "ArgumentList"; pArgumentList.ParameterType = typeof(object[]); pArgumentList.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByStaticParameters", Position = 3, Mandatory = true }); pArgumentList.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("ArgumentList", pArgumentList); return(dynamicParameters); }
protected object CreateVirtualMachineScaleSetGetDynamicParameters() { dynamicParameters = new RuntimeDefinedParameterDictionary(); var pResourceGroupName = new RuntimeDefinedParameter(); pResourceGroupName.Name = "ResourceGroupName"; pResourceGroupName.ParameterType = typeof(string); pResourceGroupName.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByDynamicParameters", Position = 1, Mandatory = true }); pResourceGroupName.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("ResourceGroupName", pResourceGroupName); var pVMScaleSetName = new RuntimeDefinedParameter(); pVMScaleSetName.Name = "VMScaleSetName"; pVMScaleSetName.ParameterType = typeof(string); pVMScaleSetName.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByDynamicParameters", Position = 2, Mandatory = true }); pVMScaleSetName.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("VMScaleSetName", pVMScaleSetName); var pArgumentList = new RuntimeDefinedParameter(); pArgumentList.Name = "ArgumentList"; pArgumentList.ParameterType = typeof(object[]); pArgumentList.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByStaticParameters", Position = 3, Mandatory = true }); pArgumentList.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("ArgumentList", pArgumentList); return(dynamicParameters); }
protected object CreateDeploymentDeleteBySlotDynamicParameters() { dynamicParameters = new RuntimeDefinedParameterDictionary(); var pServiceName = new RuntimeDefinedParameter(); pServiceName.Name = "ServiceName"; pServiceName.ParameterType = typeof(System.String); pServiceName.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByDynamicParameters", Position = 1, Mandatory = true }); pServiceName.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("ServiceName", pServiceName); var pDeploymentSlot = new RuntimeDefinedParameter(); pDeploymentSlot.Name = "DeploymentSlot"; pDeploymentSlot.ParameterType = typeof(Microsoft.WindowsAzure.Management.Compute.Models.DeploymentSlot); pDeploymentSlot.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByDynamicParameters", Position = 2, Mandatory = true }); pDeploymentSlot.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("DeploymentSlot", pDeploymentSlot); var pArgumentList = new RuntimeDefinedParameter(); pArgumentList.Name = "ArgumentList"; pArgumentList.ParameterType = typeof(object[]); pArgumentList.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByStaticParameters", Position = 3, Mandatory = true }); pArgumentList.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("ArgumentList", pArgumentList); return(dynamicParameters); }
protected object CreateVirtualMachineRunCommandGetDynamicParameters() { dynamicParameters = new RuntimeDefinedParameterDictionary(); var pLocation = new RuntimeDefinedParameter(); pLocation.Name = "Location"; pLocation.ParameterType = typeof(string); pLocation.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByDynamicParameters", Position = 1, Mandatory = true }); pLocation.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("Location", pLocation); var pCommandId = new RuntimeDefinedParameter(); pCommandId.Name = "CommandId"; pCommandId.ParameterType = typeof(string); pCommandId.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByDynamicParameters", Position = 2, Mandatory = true }); pCommandId.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("CommandId", pCommandId); var pArgumentList = new RuntimeDefinedParameter(); pArgumentList.Name = "ArgumentList"; pArgumentList.ParameterType = typeof(object[]); pArgumentList.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByStaticParameters", Position = 3, Mandatory = true }); pArgumentList.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("ArgumentList", pArgumentList); return(dynamicParameters); }
protected object CreateVirtualMachineOSImageReplicateDynamicParameters() { dynamicParameters = new RuntimeDefinedParameterDictionary(); var pImageName = new RuntimeDefinedParameter(); pImageName.Name = "ImageName"; pImageName.ParameterType = typeof(System.String); pImageName.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByDynamicParameters", Position = 1, Mandatory = true }); pImageName.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("ImageName", pImageName); var pParameters = new RuntimeDefinedParameter(); pParameters.Name = "VirtualMachineOSImageReplicateParameters"; pParameters.ParameterType = typeof(Microsoft.WindowsAzure.Management.Compute.Models.VirtualMachineOSImageReplicateParameters); pParameters.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByDynamicParameters", Position = 2, Mandatory = true }); pParameters.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("VirtualMachineOSImageReplicateParameters", pParameters); var pArgumentList = new RuntimeDefinedParameter(); pArgumentList.Name = "ArgumentList"; pArgumentList.ParameterType = typeof(object[]); pArgumentList.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByStaticParameters", Position = 3, Mandatory = true }); pArgumentList.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("ArgumentList", pArgumentList); return(dynamicParameters); }
protected object CreateVirtualMachineOSImageDeleteDynamicParameters() { dynamicParameters = new RuntimeDefinedParameterDictionary(); var pImageName = new RuntimeDefinedParameter(); pImageName.Name = "ImageName"; pImageName.ParameterType = typeof(System.String); pImageName.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByDynamicParameters", Position = 1, Mandatory = true }); pImageName.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("ImageName", pImageName); var pDeleteFromStorage = new RuntimeDefinedParameter(); pDeleteFromStorage.Name = "DeleteFromStorage"; pDeleteFromStorage.ParameterType = typeof(System.Boolean); pDeleteFromStorage.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByDynamicParameters", Position = 2, Mandatory = true }); pDeleteFromStorage.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("DeleteFromStorage", pDeleteFromStorage); var pArgumentList = new RuntimeDefinedParameter(); pArgumentList.Name = "ArgumentList"; pArgumentList.ParameterType = typeof(object[]); pArgumentList.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByStaticParameters", Position = 3, Mandatory = true }); pArgumentList.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("ArgumentList", pArgumentList); return(dynamicParameters); }
protected object CreateHostedServiceGetExtensionDynamicParameters() { dynamicParameters = new RuntimeDefinedParameterDictionary(); var pServiceName = new RuntimeDefinedParameter(); pServiceName.Name = "ServiceName"; pServiceName.ParameterType = typeof(System.String); pServiceName.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByDynamicParameters", Position = 1, Mandatory = true }); pServiceName.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("ServiceName", pServiceName); var pExtensionId = new RuntimeDefinedParameter(); pExtensionId.Name = "ExtensionId"; pExtensionId.ParameterType = typeof(System.String); pExtensionId.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByDynamicParameters", Position = 2, Mandatory = true }); pExtensionId.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("ExtensionId", pExtensionId); var pArgumentList = new RuntimeDefinedParameter(); pArgumentList.Name = "ArgumentList"; pArgumentList.ParameterType = typeof(object[]); pArgumentList.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByStaticParameters", Position = 3, Mandatory = true }); pArgumentList.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("ArgumentList", pArgumentList); return(dynamicParameters); }
/// <summary> /// This function is part of the IDynamicParameters interface. /// PowerShell uses it to generate parameters dynamically. /// We have to generate -ResourceType parameter dynamically because the array /// of resources that we used to validate against are not generated before compile time, /// i.e. [ValidateSet(ArrayGeneratedAtRunTime)] will throw an error for parameters /// that are not generated dynamically. /// </summary> public object GetDynamicParameters() { if (_dynamicParameters == null) { _dynamicParameters = new RuntimeDefinedParameterDictionary(); _dynamicParameters.Add("ResourceType", GenerateResourceTypeParameter(mandatory: true)); } return(_dynamicParameters); }
private object NameSpaceDynamicParameter() { RuntimeDefinedParameterDictionary dynamicParameters = new RuntimeDefinedParameterDictionary(); Collection <Attribute> atts = new Collection <Attribute>(); ParameterAttribute parameterAttribute = new ParameterAttribute(); atts.Add(parameterAttribute); dynamicParameters.Add("namespace", new RuntimeDefinedParameter("namespace", typeof(string), atts)); return(dynamicParameters); }
private RuntimeDefinedParameterDictionary GetInvokeItemDynamicParameters() { var iiDynamicParameters = new RuntimeDefinedParameterDictionary(); // copy shared parameters to ii dynamic parameters foreach (string key in _sharedDynamicParameters.Keys) { iiDynamicParameters.Add(key, _sharedDynamicParameters[key]); } // add an invoke-item specific dynamic parameter for reflection-only loading var dynamic = new DynamicParameterBuilder(); dynamic.AddParam <SwitchParameter>(REFLECTION_ONLY, false, null); iiDynamicParameters.Add(REFLECTION_ONLY, dynamic.GetDictionary()[REFLECTION_ONLY]); return(iiDynamicParameters); }
public object GetDynamicParameters() { var runtimeParamDictionary = new RuntimeDefinedParameterDictionary(); var attributes = new Collection <Attribute>(); attributes.Add(new ParameterAttribute()); //This parameter has a ParameterAttribute and is considered a dynamic parameter. var dynamicParam = new RuntimeDefinedParameter("DynamicParam", typeof(string), attributes); //This parameter is missing a ParameterAttribute. While it is technically still a dynamic parameter, //it is not considered part of any parameter set and cannot be used. var irrelevantParam = new RuntimeDefinedParameter("IrrelevantParam", typeof(string), new Collection <Attribute>()); runtimeParamDictionary.Add("DynamicParam", dynamicParam); runtimeParamDictionary.Add("IrrelevantParam", irrelevantParam); return(runtimeParamDictionary); }
private RuntimeDefinedParameterDictionary BuildItemPropertyParameters(ValidateSetAttribute validateSet) { var propertyNameParameter = new RuntimeDefinedParameter("TreeStorePropertyName", typeof(string), new Collection <Attribute>()); propertyNameParameter.Attributes.Add(this.ParameterAttribute()); propertyNameParameter.Attributes.Add(validateSet); var parameter = new RuntimeDefinedParameterDictionary(); parameter.Add(propertyNameParameter.Name, propertyNameParameter); return(parameter); }
protected object CreateVirtualMachineExtensionListVersionsDynamicParameters() { dynamicParameters = new RuntimeDefinedParameterDictionary(); var pPublisherName = new RuntimeDefinedParameter(); pPublisherName.Name = "PublisherName"; pPublisherName.ParameterType = typeof(System.String); pPublisherName.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByDynamicParameters", Position = 1, Mandatory = true }); pPublisherName.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("PublisherName", pPublisherName); var pExtensionName = new RuntimeDefinedParameter(); pExtensionName.Name = "ExtensionName"; pExtensionName.ParameterType = typeof(System.String); pExtensionName.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByDynamicParameters", Position = 2, Mandatory = true }); pExtensionName.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("ExtensionName", pExtensionName); var pArgumentList = new RuntimeDefinedParameter(); pArgumentList.Name = "ArgumentList"; pArgumentList.ParameterType = typeof(object[]); pArgumentList.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByStaticParameters", Position = 3, Mandatory = true }); pArgumentList.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("ArgumentList", pArgumentList); return dynamicParameters; }
protected object CreateVirtualMachineVMImageDeleteDynamicParameters() { dynamicParameters = new RuntimeDefinedParameterDictionary(); var pVMImageName = new RuntimeDefinedParameter(); pVMImageName.Name = "VMImageName"; pVMImageName.ParameterType = typeof(System.String); pVMImageName.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByDynamicParameters", Position = 1, Mandatory = true }); pVMImageName.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("VMImageName", pVMImageName); var pDeleteFromStorage = new RuntimeDefinedParameter(); pDeleteFromStorage.Name = "DeleteFromStorage"; pDeleteFromStorage.ParameterType = typeof(System.Boolean); pDeleteFromStorage.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByDynamicParameters", Position = 2, Mandatory = true }); pDeleteFromStorage.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("DeleteFromStorage", pDeleteFromStorage); var pArgumentList = new RuntimeDefinedParameter(); pArgumentList.Name = "ArgumentList"; pArgumentList.ParameterType = typeof(object[]); pArgumentList.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByStaticParameters", Position = 3, Mandatory = true }); pArgumentList.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("ArgumentList", pArgumentList); return dynamicParameters; }
protected override object NewDriveDynamicParameters() { RuntimeDefinedParameterDictionary dynamicParameters = new RuntimeDefinedParameterDictionary(); Collection <Attribute> atts = new Collection <Attribute>(); ParameterAttribute parameterAttribute = new ParameterAttribute(); parameterAttribute.Mandatory = true; atts.Add(parameterAttribute); dynamicParameters.Add("path", new RuntimeDefinedParameter("path", typeof(string), atts)); return(dynamicParameters); }
public object GetDynamicParameters() { var parameters = new RuntimeDefinedParameterDictionary(); RuntimeDefinedParameter sourceNameParameter; if (TryGetExistingContextNameParameter(SourceParameterName, NameParameterSet, out sourceNameParameter)) { parameters.Add(sourceNameParameter.Name, sourceNameParameter); var attributes = new Collection <Attribute>() { new ParameterAttribute { Position = 1, Mandatory = true, HelpMessage = "The new name of the context" }, new ValidateNotNullOrEmptyAttribute() }; var targetNameParameter = new RuntimeDefinedParameter(TargetParameterName, typeof(string), attributes); parameters.Add(targetNameParameter.Name, targetNameParameter); } return(parameters); }
public object GetDynamicParameters() { var parameters = new RuntimeDefinedParameterDictionary(); RuntimeDefinedParameter nameParameter; if (TryGetExistingContextNameParameter("Name", ContextNameParameterSet, out nameParameter)) { parameters.Add(nameParameter.Name, nameParameter); } return(parameters); }
public new object GetDynamicParameters() { var parameters = new RuntimeDefinedParameterDictionary(); RuntimeDefinedParameter namedParameter; if (ProviderConfiguration.TryGetProvideServiceParameter(privateEndpointTypeName, NamedContextParameterSet, out namedParameter)) { parameters.Add(privateEndpointTypeName, namedParameter); } DynamicParameters = parameters; return(parameters); }
/// <summary> /// Add -MachineType and -ImageType parameter (they belong to "ByNodeConfigValues" parameter set). /// </summary> protected override void PopulateDynamicParameter(string project, string zone, RuntimeDefinedParameterDictionary dynamicParamDict) { // Gets all the valid machine types of this zone and project combination. string[] machineTypes = GetMachineTypes(Project, Zone); RuntimeDefinedParameter machineTypeParam = GenerateRuntimeParameter( parameterName: "MachineType", helpMessage: "The Google Compute Engine machine type to use for node in this node pool.", validSet: machineTypes, parameterSetNames: ParameterSetNames.ByNodeConfigValues); dynamicParamDict.Add("MachineType", machineTypeParam); // Gets all the valid image types of this zone and project combination. string[] imageTypes = GetImageTypes(Project, Zone); RuntimeDefinedParameter imageTypeParam = GenerateRuntimeParameter( parameterName: "ImageType", helpMessage: "The image type to use for node in this node pool.", validSet: imageTypes, parameterSetNames: ParameterSetNames.ByNodeConfigValues); dynamicParamDict.Add("ImageType", imageTypeParam); }
public virtual object GetDynamicParameters() { IsVerbose = MyInvocation.BoundParameters.ContainsKey("Verbose") && ((SwitchParameter)MyInvocation.BoundParameters["Verbose"]).ToBool(); try { PrepareTemplate(); var paramDictionary = new RuntimeDefinedParameterDictionary(); var keys = GetAttributes(); if (keys != null) { if (IsVerbose) { var m = string.Format("top level attributes: {0}", string.Join(", ", keys)); Host.UI.WriteVerboseLine(m); } foreach (var key in keys) { var attribute = new ParameterAttribute { ValueFromPipeline = true, ValueFromPipelineByPropertyName = true }; var attributeCollection = new Collection <System.Attribute> { attribute }; var param = new RuntimeDefinedParameter(key, typeof(object), attributeCollection); paramDictionary.Add(key, param); } RuntimeDefinedParameterDictionary = paramDictionary; } else { Host.UI.WriteWarningLine("no formal argument"); } return(paramDictionary); } catch (Exception e) { var m = string.Format("In GetDynamicParameters: {0}", e); if (IsVerbose) { Host.UI.WriteVerboseLine(m); } throw; } }
internal static void AddDynamicParameter(this RuntimeDefinedParameterDictionary dict, string name, Type type, bool mandatory, int?position = null) { Collection <Attribute> attrs = new Collection <Attribute>(); ParameterAttribute attr = new ParameterAttribute { Mandatory = mandatory }; if (position.HasValue) { attr.Position = position.Value; } attrs.Add(attr); dict.Add(name, new RuntimeDefinedParameter(name, type, attrs)); }
protected override object NewDriveDynamicParameters() { var parameters = new RuntimeDefinedParameterDictionary(); parameters.Add("CimSession", new RuntimeDefinedParameter("CimSession", typeof(CimSession), new Collection <Attribute>() { new ParameterAttribute() { ValueFromPipeline = true, }, new ValidateNotNullOrEmptyAttribute(), new NoCompletionAttribute() })); return(parameters); }
public override object GetDynamicParameters() { dynamicParameters = new RuntimeDefinedParameterDictionary(); var pResourceGroupName = new RuntimeDefinedParameter(); pResourceGroupName.Name = "ResourceGroupName"; pResourceGroupName.ParameterType = typeof(string); pResourceGroupName.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByDynamicParameters", Position = 1, Mandatory = false, ValueFromPipelineByPropertyName = true, ValueFromPipeline = false }); pResourceGroupName.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("ResourceGroupName", pResourceGroupName); var pDiskName = new RuntimeDefinedParameter(); pDiskName.Name = "DiskName"; pDiskName.ParameterType = typeof(string); pDiskName.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByDynamicParameters", Position = 2, Mandatory = false, ValueFromPipelineByPropertyName = true, ValueFromPipeline = false }); pDiskName.Attributes.Add(new AliasAttribute("Name")); pDiskName.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("DiskName", pDiskName); return(dynamicParameters); }
public void AddParam <T>(string name, bool mandatory, string parameterSet) { ParameterAttribute pa = new ParameterAttribute(); pa.ParameterSetName = parameterSet; pa.Mandatory = mandatory; RuntimeDefinedParameter rdp = new RuntimeDefinedParameter(); rdp.Name = name; rdp.ParameterType = typeof(T); rdp.Attributes.Add(pa); _dict.Add(name, rdp); }
protected object CreateOperatingSystemListDynamicParameters() { dynamicParameters = new RuntimeDefinedParameterDictionary(); var pArgumentList = new RuntimeDefinedParameter(); pArgumentList.Name = "ArgumentList"; pArgumentList.ParameterType = typeof(object[]); pArgumentList.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByStaticParameters", Position = 1, Mandatory = true }); pArgumentList.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("ArgumentList", pArgumentList); return dynamicParameters; }
private static RuntimeDefinedParameterDictionary ParseTemplateAndExtractParameters(string templateContent, Hashtable templateParameterObject, string templateParameterFilePath, string[] staticParameters) { RuntimeDefinedParameterDictionary dynamicParameters = new RuntimeDefinedParameterDictionary(); if (!string.IsNullOrEmpty(templateContent)) { TemplateFile templateFile = null; try { templateFile = JsonConvert.DeserializeObject <TemplateFile>(templateContent); if (templateFile.Parameters == null) { return(dynamicParameters); } } catch (Exception e) { // Can't parse the template file, do not generate dynamic parameters Debug.WriteLine("Unable to parse template file. The exception received was: " + e.Message); return(dynamicParameters); } foreach (KeyValuePair <string, TemplateFileParameterV1> parameter in templateFile.Parameters) { RuntimeDefinedParameter dynamicParameter = ConstructDynamicParameter(staticParameters, parameter); dynamicParameters.Add(dynamicParameter.Name, dynamicParameter); } } if (templateParameterObject != null) { UpdateParametersWithObject(dynamicParameters, templateParameterObject); } if (templateParameterFilePath != null && FileUtilities.DataStore.FileExists(templateParameterFilePath)) { var parametersFromFile = ParseTemplateParameterFileContents(templateParameterFilePath); UpdateParametersWithObject(dynamicParameters, new Hashtable(parametersFromFile)); } if (templateParameterFilePath != null && Uri.IsWellFormedUriString(templateParameterFilePath, UriKind.Absolute)) { var parametersFromUri = ParseTemplateParameterContent(GeneralUtilities.DownloadFile(templateParameterFilePath)); UpdateParametersWithObject(dynamicParameters, new Hashtable(parametersFromUri)); } return(dynamicParameters); }
protected object CreateResourceSkuListDynamicParameters() { dynamicParameters = new RuntimeDefinedParameterDictionary(); var pArgumentList = new RuntimeDefinedParameter(); pArgumentList.Name = "ArgumentList"; pArgumentList.ParameterType = typeof(object[]); pArgumentList.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByStaticParameters", Position = 1, Mandatory = true }); pArgumentList.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("ArgumentList", pArgumentList); return(dynamicParameters); }
public object GetDynamicParameters() { var runtimeDefinedParameterDictionary = new RuntimeDefinedParameterDictionary(); var queryParamAttr = new Collection <Attribute> { }; queryParamAttr.Add(new ParameterAttribute { Mandatory = true, ParameterSetName = "Set3" }); runtimeDefinedParameterDictionary.Add( "Query", new RuntimeDefinedParameter("Query", typeof(string), queryParamAttr) ); return(runtimeDefinedParameterDictionary); }
/// <summary> /// Returns an instance of an object that defines the /// dynamic parameters for this /// <see cref="T:System.Management.Automation.Cmdlet" /> or <see cref="T:System.Management.Automation.Provider.CmdletProvider" />. /// </summary> /// <returns>This method should return an object that has properties and fields /// decorated with parameter attributes similar to a /// <see cref="T:System.Management.Automation.Cmdlet" /> or <see cref="T:System.Management.Automation.Provider.CmdletProvider" />. /// These attributes include <see cref="T:System.Management.Automation.ParameterAttribute" />, /// <see cref="T:System.Management.Automation.AliasAttribute" />, argument transformation and /// validation attributes, etc. /// Alternately, it can return a /// <see cref="T:System.Management.Automation.RuntimeDefinedParameterDictionary" /> /// instead. /// The <see cref="T:System.Management.Automation.Cmdlet" /> or <see cref="T:System.Management.Automation.Provider.CmdletProvider" /> /// should hold on to a reference to the object which it returns from /// this method, since the argument values for the dynamic parameters /// specified by that object will be set in that object. /// This method will be called after all formal (command-line) /// parameters are set, but before <see cref="M:System.Management.Automation.Cmdlet.BeginProcessing" /> /// is called and before any incoming pipeline objects are read. /// Therefore, parameters which allow input from the pipeline /// may not be set at the time this method is called, /// even if the parameters are mandatory.</returns> public object GetDynamicParameters() { var parameterName = "AccountName"; var runTimeParameterDictionary = new RuntimeDefinedParameterDictionary(); var attributeCollection = new Collection <Attribute>(); var parameterAttribute = new ParameterAttribute(); parameterAttribute.Mandatory = true; parameterAttribute.Position = 1; attributeCollection.Add(parameterAttribute); var arraySet = AzureDevOpsConfiguration.Config.Accounts.GetAccountNames(); var validateSetAttribute = new ValidateSetAttribute(arraySet); attributeCollection.Add(validateSetAttribute); var runtimeParameter = new RuntimeDefinedParameter(parameterName, typeof(string), attributeCollection); runTimeParameterDictionary.Add(parameterName, runtimeParameter); return(runTimeParameterDictionary); }
public object Create() { var type = _metadata.GetMappedClass(EntityMode.Poco); var parameters = new RuntimeDefinedParameterDictionary(); var attrs = from prop in type.GetProperties() // where prop.Name != _metadata.IdentifierPropertyName select new RuntimeDefinedParameter( prop.Name, prop.PropertyType, new Collection<Attribute> { new ParameterAttribute() } ); attrs.ToList().ForEach(attr => parameters.Add(attr.Name, attr)); return parameters; }
public object GetDynamicParameters() { if (_runtimeParamsDict == null) { ParameterAttribute paramAttribute = new ParameterAttribute(); paramAttribute.Mandatory = true; Collection <Attribute> nameAttributes = new Collection <Attribute>(new Attribute[] { new ValidateSetAttribute(Enum.GetNames(typeof(HistoricalData.HistoricalDataType))), new ValidateNotNullOrEmptyAttribute(), paramAttribute }); _runtimeParamsDict = new RuntimeDefinedParameterDictionary(); _runtimeParamsDict.Add("HistoricalDataType", new RuntimeDefinedParameter("HistoricalDataType", typeof(string), nameAttributes)); } return(_runtimeParamsDict); }
//https://msdn.microsoft.com/en-us/library/bb336630(v=vs.110).aspx /// <summary> /// <para type="description">The paper size. Portrate unless otherwise specified.</para> /// </summary> /// <returns></returns> public object GetDynamicParameters() { IEnumerable <string> pageSizes = typeof(PageSize).GetFields().Select(x => x.Name); var runtimeDefinedParameterDictionary = new RuntimeDefinedParameterDictionary(); var attrib = new Collection <Attribute>() { new ParameterAttribute() { HelpMessage = "A Slack Emoji to use as the avatar", Mandatory = true, Position = 1 }, new ValidateSetAttribute(pageSizes.ToArray()) }; var parameter = new RuntimeDefinedParameter("PageSize", typeof(String), attrib); runtimeDefinedParameterDictionary.Add("PageSize", parameter); _staticStorage = runtimeDefinedParameterDictionary; return(runtimeDefinedParameterDictionary); }
object IDynamicParameters.GetDynamicParameters() { ResolveManager(); SPModelDescriptor descriptor = SPModelDescriptor.Resolve(this.TypeName); RuntimeDefinedParameterDictionary parameters = new RuntimeDefinedParameterDictionary(); foreach (PropertyInfo property in descriptor.ModelType.GetProperties()) { if (property.CanWrite || property.PropertyType.IsOf(typeof(IList <>))) { ParameterAttribute attribute = new ParameterAttribute(); attribute.ParameterSetName = "__AllParameterSets"; parameters.Add(property.Name, new RuntimeDefinedParameter(property.Name, property.PropertyType, new Collection <Attribute> { attribute })); } } modelParameters = parameters; return(parameters); }
public object GetDynamicParameters() { var parameters = new RuntimeDefinedParameterDictionary(); // add `-SubscriptionId` if the cmdlet has [SupportsSubscriptionId] attribute if (GetType().IsDefined(typeof(SupportsSubscriptionIdAttribute), true)) { parameters.Add(SubscriptionIdParameter, new RuntimeDefinedParameter( SubscriptionIdParameter, typeof(string), new Collection <Attribute>() { new ParameterAttribute { HelpMessage = Resources.SubscriptionIdHelpMessage, Mandatory = false, ValueFromPipelineByPropertyName = true } } )); } return(parameters); }
public object GetDynamicParameters() { if (_runtimeParamsDict == null) { ParameterAttribute paramAttribute = new ParameterAttribute(); paramAttribute.Mandatory = true; string[] validNames = IndicatorAndStrategyContainer.Instance.Indicators.Select(indicator => indicator.Name).ToArray(); Collection<Attribute> nameAttributes = new Collection<Attribute>(new Attribute[] { new ValidateSetAttribute(validNames), new ValidateNotNullOrEmptyAttribute(), paramAttribute }); var nameParam = new RuntimeDefinedParameter("Name", typeof(string), nameAttributes); _runtimeParamsDict = new RuntimeDefinedParameterDictionary(); _runtimeParamsDict.Add("Name", nameParam); } return _runtimeParamsDict; }
private RuntimeDefinedParameterDictionary GetInvokeItemDynamicParameters() { var iiDynamicParameters = new RuntimeDefinedParameterDictionary(); // copy shared parameters to ii dynamic parameters foreach (string key in _sharedDynamicParameters.Keys) { iiDynamicParameters.Add(key, _sharedDynamicParameters[key]); } // add an invoke-item specific dynamic parameter for reflection-only loading var dynamic = new DynamicParameterBuilder(); dynamic.AddParam<SwitchParameter>(REFLECTION_ONLY, false, null); iiDynamicParameters.Add(REFLECTION_ONLY, dynamic.GetDictionary()[REFLECTION_ONLY]); return iiDynamicParameters; }
public override object GetDynamicParameters() { dynamicParameters = new RuntimeDefinedParameterDictionary(); var pResourceGroupName = new RuntimeDefinedParameter(); pResourceGroupName.Name = "ResourceGroupName"; pResourceGroupName.ParameterType = typeof(string); pResourceGroupName.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByDynamicParameters", Position = 1, Mandatory = false, ValueFromPipeline = false }); pResourceGroupName.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByDynamicParametersForFriendMethod", Position = 1, Mandatory = false, ValueFromPipeline = false }); pResourceGroupName.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("ResourceGroupName", pResourceGroupName); var pVMScaleSetName = new RuntimeDefinedParameter(); pVMScaleSetName.Name = "VMScaleSetName"; pVMScaleSetName.ParameterType = typeof(string); pVMScaleSetName.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByDynamicParameters", Position = 2, Mandatory = false, ValueFromPipeline = false }); pVMScaleSetName.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByDynamicParametersForFriendMethod", Position = 2, Mandatory = false, ValueFromPipeline = false }); pVMScaleSetName.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("VMScaleSetName", pVMScaleSetName); var pInstanceId = new RuntimeDefinedParameter(); pInstanceId.Name = "InstanceId"; pInstanceId.ParameterType = typeof(string); pInstanceId.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByDynamicParameters", Position = 3, Mandatory = false, ValueFromPipeline = false }); pInstanceId.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByDynamicParametersForFriendMethod", Position = 3, Mandatory = false, ValueFromPipeline = false }); pInstanceId.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("InstanceId", pInstanceId); var pInstanceView = new RuntimeDefinedParameter(); pInstanceView.Name = "InstanceView"; pInstanceView.ParameterType = typeof(SwitchParameter); pInstanceView.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByDynamicParametersForFriendMethod", Position = 4, Mandatory = true }); pInstanceView.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByStaticParametersForFriendMethod", Position = 5, Mandatory = true }); pInstanceView.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("InstanceView", pInstanceView); return dynamicParameters; }
/// <summary> /// Adds http error action parameters to PowerShell. /// </summary> /// <param name="create">true if parameters added for create scenario and false for update scenario.</param> /// <returns>PowerShell parameters.</returns> internal RuntimeDefinedParameterDictionary AddHttpErrorActionParameters(bool create = true) { var errorActionMethodAttributes = new Collection<Attribute> { new ParameterAttribute { Mandatory = create ? true : false, HelpMessage = "The Method for Http and Https Action types (GET, PUT, POST, HEAD or DELETE).", }, new ValidateSetAttribute(Constants.HttpMethodGET, Constants.HttpMethodPUT, Constants.HttpMethodPOST, Constants.HttpMethodDELETE) { IgnoreCase = true, } }; var errorActionUriAttributes = new Collection<Attribute> { new ParameterAttribute { Mandatory = create ? true : false, HelpMessage = "The Uri for error job action.", }, new ValidateNotNullOrEmptyAttribute() }; var errorActionRequestBodyAttributes = new Collection<Attribute> { new ParameterAttribute { Mandatory = false, HelpMessage = "The Body for PUT and POST job actions.", }, new ValidateNotNullOrEmptyAttribute() }; var errorActionHeadersAttributes = new Collection<Attribute> { new ParameterAttribute { Mandatory = false, HelpMessage = "The header collection." }, new ValidateNotNullOrEmptyAttribute() }; var errorActionHttpAuthenticationTypeAttributes = new Collection<Attribute> { new ParameterAttribute { Mandatory = false, HelpMessage = "The Http Authentication type." }, new ValidateSetAttribute(Constants.HttpAuthenticationNone, Constants.HttpAuthenticationClientCertificate, Constants.HttpAuthenticationActiveDirectoryOAuth, Constants.HttpAuthenticationBasic) { IgnoreCase = true } }; this._errorActionMethod = new RuntimeDefinedParameter("ErrorActionMethod", typeof(string), errorActionMethodAttributes); this._errorActionUri = new RuntimeDefinedParameter("ErrorActionUri", typeof(Uri), errorActionUriAttributes); this._errorActionRequestBody = new RuntimeDefinedParameter("ErrorActionRequestBody", typeof(string), errorActionRequestBodyAttributes); this._errorActionHeaders = new RuntimeDefinedParameter("ErrorActionHeaders", typeof(Hashtable), errorActionHeadersAttributes); this._errorActionHttpAuthenticationType = new RuntimeDefinedParameter("ErrorActionHttpAuthenticationType", typeof(string), errorActionHttpAuthenticationTypeAttributes); var runtimeDefinedParameterDictionary = new RuntimeDefinedParameterDictionary(); runtimeDefinedParameterDictionary.Add("ErrorActionMethod", this._errorActionMethod); runtimeDefinedParameterDictionary.Add("ErrorActionUri", this._errorActionUri); runtimeDefinedParameterDictionary.Add("ErrorActionRequestBody", this._errorActionRequestBody); runtimeDefinedParameterDictionary.Add("ErrorActionHeaders", this._errorActionHeaders); runtimeDefinedParameterDictionary.Add("ErrorActionHttpAuthenticationType", this._errorActionHttpAuthenticationType); runtimeDefinedParameterDictionary.AddRange(this.AddHttpErrorActionClientCertificateAuthenticationTypeParameters()); runtimeDefinedParameterDictionary.AddRange(this.AddHttpErrorActionBasicAuthenticationTypeParameters()); runtimeDefinedParameterDictionary.AddRange(this.AddHttpErrorActionActiveDirectoryOAuthAuthenticationTypeParameters()); return runtimeDefinedParameterDictionary; }
/// <summary> /// Adds Storage queue error action parameters. /// </summary> /// <param name="create">true if parameters added for create scenario and false for update scenario.</param> /// <returns>PowerShell parameters.</returns> internal RuntimeDefinedParameterDictionary AddStorageQueueErrorActionParameters(bool create = true) { var errorActionStorageAccountAttributes = new Collection<Attribute> { new ParameterAttribute { Mandatory = create ? true : false, HelpMessage = "The Storage account name.", }, new ValidateNotNullOrEmptyAttribute() }; var errorActionStorageQueueAttributes = new Collection<Attribute> { new ParameterAttribute { Mandatory = create ? true : false, HelpMessage = "The Storage Queue name.", }, new ValidateNotNullOrEmptyAttribute() }; var errorActionStorageSASTokenAttributes = new Collection<Attribute> { new ParameterAttribute { Mandatory = create ? true : false, HelpMessage = "The SAS token for storage queue.", }, new ValidateNotNullOrEmptyAttribute() }; var errorActionStorageQueueMessageBodyAttributes = new Collection<Attribute> { new ParameterAttribute { Mandatory = create ? true : false, HelpMessage = "The Body for Storage job actions." }, new ValidateNotNullOrEmptyAttribute() }; this._errorActionStorageAccount = new RuntimeDefinedParameter("ErrorActionStorageAccount", typeof(string), errorActionStorageAccountAttributes); this._errorActionStorageQueue = new RuntimeDefinedParameter("ErrorActionStorageQueue", typeof(string), errorActionStorageQueueAttributes); this._errorActionStorageSASToken = new RuntimeDefinedParameter("ErrorActionStorageSASToken", typeof(string), errorActionStorageSASTokenAttributes); this._errorActionStorageQueueMessageBody = new RuntimeDefinedParameter("ErrorActionStorageQueueMessageBody", typeof(string), errorActionStorageQueueMessageBodyAttributes); var runtimeDefinedParameterDictionary = new RuntimeDefinedParameterDictionary(); runtimeDefinedParameterDictionary.Add("ErrorActionStorageAccount", this._errorActionStorageAccount); runtimeDefinedParameterDictionary.Add("ErrorActionStorageQueue", this._errorActionStorageQueue); runtimeDefinedParameterDictionary.Add("ErrorActionStorageSASToken", this._errorActionStorageSASToken); runtimeDefinedParameterDictionary.Add("ErrorActionStorageQueueMessageBody", this._errorActionStorageQueueMessageBody); return runtimeDefinedParameterDictionary; }
public override object GetDynamicParameters() { dynamicParameters = new RuntimeDefinedParameterDictionary(); var pResourceGroupName = new RuntimeDefinedParameter(); pResourceGroupName.Name = "ResourceGroupName"; pResourceGroupName.ParameterType = typeof(string); pResourceGroupName.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByDynamicParameters", Position = 1, Mandatory = true, ValueFromPipeline = false }); pResourceGroupName.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("ResourceGroupName", pResourceGroupName); var pName = new RuntimeDefinedParameter(); pName.Name = "Name"; pName.ParameterType = typeof(string); pName.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByDynamicParameters", Position = 2, Mandatory = true, ValueFromPipeline = false }); pName.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("Name", pName); var pParameters = new RuntimeDefinedParameter(); pParameters.Name = "VirtualMachineScaleSet"; pParameters.ParameterType = typeof(VirtualMachineScaleSet); pParameters.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByDynamicParameters", Position = 3, Mandatory = true, ValueFromPipeline = true }); pParameters.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("VirtualMachineScaleSet", pParameters); return dynamicParameters; }
/// <summary> /// Add service bus topic error action parameters. /// </summary> /// <param name="create">true if parameters added for create scenario and false for update scenario.</param> /// <returns>PowerShell parameters.</returns> internal RuntimeDefinedParameterDictionary AddServiceBusTopicErrorActionParameters(bool create = true) { var errorActionServiceBusTopicPathAttributes = new Collection<Attribute> { new ParameterAttribute { Mandatory = create ? true : false, HelpMessage = "Service bus topic path.", }, new ValidateNotNullOrEmptyAttribute() }; this._errorActionServiceBusTopicPath = new RuntimeDefinedParameter("ErrorActionServiceBusTopicPath", typeof(string), errorActionServiceBusTopicPathAttributes); var runTimeDefinedParameterDictionary = new RuntimeDefinedParameterDictionary(); runTimeDefinedParameterDictionary.Add("ErrorActionServiceBusTopicPath", this._errorActionServiceBusTopicPath); runTimeDefinedParameterDictionary.AddRange(this.AddServiceBusErrorActionParameters(create)); return runTimeDefinedParameterDictionary; }
private static RuntimeDefinedParameterDictionary GetRuntimeDefinedParameterDictionary(List<string> tableNames) { var runtimeDefinedParameterDictionary = new RuntimeDefinedParameterDictionary(); var attributes = new Collection<Attribute> { new ParameterAttribute { Position = 2, HelpMessage = "Table names" }, }; if (tableNames != null && tableNames.Any()) { attributes.Add(new ValidateSetAttribute(tableNames.ToArray())); } runtimeDefinedParameterDictionary.Add("Tables", new RuntimeDefinedParameter("Tables", typeof (string[]), attributes)); return runtimeDefinedParameterDictionary; }
/// <summary> /// Add service bus error action parameters. /// </summary> /// <param name="create">true if parameters added for create scenario and false for update scenario.</param> /// <returns>PowerShell parameters.</returns> internal RuntimeDefinedParameterDictionary AddServiceBusErrorActionParameters(bool create) { var errorActionServiceBusNamespaceAttributes = new Collection<Attribute> { new ParameterAttribute { Mandatory = create ? true : false, HelpMessage = "Service bus namespace.", }, new ValidateNotNullOrEmptyAttribute() }; var errorActionServiceBusTransportTypeAttributes = new Collection<Attribute> { new ParameterAttribute { Mandatory = create ? true : false, HelpMessage = "Service bus transport type.", }, new ValidateNotNullOrEmptyAttribute() }; var errorActionServiceBusMessageAttributes = new Collection<Attribute> { new ParameterAttribute { Mandatory = create ? true : false, HelpMessage = "Service bus queue message.", }, new ValidateNotNullOrEmptyAttribute() }; var errorActionServiceBusSasKeyNameAttributes = new Collection<Attribute> { new ParameterAttribute { Mandatory = create ? true : false, HelpMessage = "Shared access signature key name.", }, new ValidateNotNullOrEmptyAttribute() }; var errorActionServiceBusSasKeyValueAttributes = new Collection<Attribute> { new ParameterAttribute { Mandatory = create ? true : false, HelpMessage = "Shared access signature key value.", }, new ValidateNotNullOrEmptyAttribute() }; this._errorActionServiceBusNamespace = new RuntimeDefinedParameter("ErrorActionServiceBusNamespace", typeof(string), errorActionServiceBusNamespaceAttributes); this._errorActionServiceBusTransportType = new RuntimeDefinedParameter("ErrorActionServiceBusTransportType", typeof(string), errorActionServiceBusTransportTypeAttributes); this._errorActionServiceBusMessage = new RuntimeDefinedParameter("ErrorActionServiceBusMessage", typeof(string), errorActionServiceBusMessageAttributes); this._errorActionServiceBusSasKeyName = new RuntimeDefinedParameter("ErrorActionServiceBusSasKeyName", typeof(string), errorActionServiceBusSasKeyNameAttributes); this._errorActionServiceBusSasKeyValue = new RuntimeDefinedParameter("ErrorActionServiceBusSasKeyValue", typeof(string), errorActionServiceBusSasKeyValueAttributes); var runTimeDefinedParameterDictionary = new RuntimeDefinedParameterDictionary(); runTimeDefinedParameterDictionary.Add("ErrorActionServiceBusNamespace", this._errorActionServiceBusNamespace); runTimeDefinedParameterDictionary.Add("ErrorActionServiceBusTransportType", this._errorActionServiceBusTransportType); runTimeDefinedParameterDictionary.Add("ErrorActionServiceBusMessage", this._errorActionServiceBusMessage); runTimeDefinedParameterDictionary.Add("ErrorActionServiceBusSasKeyName", this._errorActionServiceBusSasKeyName); runTimeDefinedParameterDictionary.Add("ErrorActionServiceBusSasKeyValue", this._errorActionServiceBusSasKeyValue); return runTimeDefinedParameterDictionary; }
/// <summary> /// Adds client certificate authentication parameters for http error action. /// </summary> /// <returns>PowerShell parameters.</returns> internal RuntimeDefinedParameterDictionary AddHttpErrorActionClientCertificateAuthenticationTypeParameters() { var errorActionClientCertificatePfxAttributes = new Collection<Attribute> { new ParameterAttribute { Mandatory = false, HelpMessage = "The file name of client certificate.", }, new ValidateNotNullOrEmptyAttribute() }; var errorActionClientCertificatePasswordAttributes = new Collection<Attribute> { new ParameterAttribute { Mandatory = false, HelpMessage = "The password for the pfx.", }, new ValidateNotNullOrEmptyAttribute() }; this._errorActionClientCertificatePfx = new RuntimeDefinedParameter("ErrorActionClientCertificatePfx", typeof(object), errorActionClientCertificatePfxAttributes); this._errorActionClientCertificatePassword = new RuntimeDefinedParameter("ErrorActionClientCertificatePassword", typeof(string), errorActionClientCertificatePasswordAttributes); var runtimeDefinedParameterDictionary = new RuntimeDefinedParameterDictionary(); runtimeDefinedParameterDictionary.Add("ErrorActionClientCertificatePfx", this._errorActionClientCertificatePfx); runtimeDefinedParameterDictionary.Add("ErrorActionClientCertificatePassword", this._errorActionClientCertificatePassword); return runtimeDefinedParameterDictionary; }
/// <summary> /// Generate dynamic parameters based on the connection strings in the Web.config. /// It will look at 2 Web.config files: /// 1. Web.config /// 2. Web.<configuration>.config (like Web.Release.config) /// This only works when -ProjectFile is used and -ConnectionString is not used. /// </summary> /// <returns>The dynamic parameters.</returns> public object GetDynamicParameters() { if (!string.IsNullOrEmpty(ProjectFile) && ConnectionString == null) { // Get the 2 Web.config files. PrepareFileFullPaths(); dynamicParameters = new RuntimeDefinedParameterDictionary(); if (string.Compare("ProjectFile", ParameterSetName) == 0) { // Parse the connection strings from the Web.config files. var names = WebsitesClient.ParseConnectionStringNamesFromWebConfig(fullWebConfigFile, fullWebConfigFileWithConfiguration); // Create a dynmaic parameter for each connection string using the same name. foreach (var name in names) { var parameter = new RuntimeDefinedParameter(); parameter.Name = name; parameter.ParameterType = typeof(string); parameter.Attributes.Add(new ParameterAttribute() { ParameterSetName = "ProjectFile", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Connection string from Web.config." } ); dynamicParameters.Add(name, parameter); } } } return dynamicParameters; }
/// <summary> /// Adds basic authentication parameters for http error action. /// </summary> /// <returns>PowerShell parameters.</returns> internal RuntimeDefinedParameterDictionary AddHttpErrorActionBasicAuthenticationTypeParameters() { var errorActionBasicUsernameAttributes = new Collection<Attribute> { new ParameterAttribute { Mandatory = false, HelpMessage = "The user name.", }, new ValidateNotNullOrEmptyAttribute() }; var errorActionBasicPasswordAttributes = new Collection<Attribute> { new ParameterAttribute { Mandatory = false, HelpMessage = "The password.", }, new ValidateNotNullOrEmptyAttribute() }; this._errorActionBasicUsername = new RuntimeDefinedParameter("ErrorActionUsername", typeof(string), errorActionBasicUsernameAttributes); this._errorActionBasicPassword = new RuntimeDefinedParameter("ErrorActionPassword", typeof(string), errorActionBasicPasswordAttributes); var runtimeDefinedParameterDictionary = new RuntimeDefinedParameterDictionary(); runtimeDefinedParameterDictionary.Add("ErrorActionUsername", this._errorActionBasicUsername); runtimeDefinedParameterDictionary.Add("ErrorActionPassword", this._errorActionBasicPassword); return runtimeDefinedParameterDictionary; }
/// <summary> /// This function is part of the IDynamicParameters interface. /// PowerShell uses it to generate parameters dynamically. /// We have to generate -ResourceType parameter dynamically because the array /// of resources that we used to validate against are not generated before compile time, /// i.e. [ValidateSet(ArrayGeneratedAtRunTime)] will throw an error for parameters /// that are not generated dynamically. /// </summary> public object GetDynamicParameters() { if (_dynamicParameters == null) { ParameterAttribute paramAttribute = new ParameterAttribute() { Mandatory = true }; ValidateSetAttribute validateSetAttribute = new ValidateSetAttribute(AllResourceTypes); validateSetAttribute.IgnoreCase = true; Collection<Attribute> attributes = new Collection<Attribute>(new Attribute[] { validateSetAttribute, paramAttribute }); // This parameter can now be thought of as: // [Parameter(Mandatory = true)] // [ValidateSet(validTypeValues)] // public string { get; set; } RuntimeDefinedParameter typeParameter = new RuntimeDefinedParameter("ResourceType", typeof(string), attributes); _dynamicParameters = new RuntimeDefinedParameterDictionary(); _dynamicParameters.Add("ResourceType", typeParameter); } return _dynamicParameters; }
public override object GetDynamicParameters() { dynamicParameters = new RuntimeDefinedParameterDictionary(); var pResourceGroupName = new RuntimeDefinedParameter(); pResourceGroupName.Name = "ResourceGroupName"; pResourceGroupName.ParameterType = typeof(string); pResourceGroupName.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByDynamicParameters", Position = 1, Mandatory = true, ValueFromPipelineByPropertyName = true, ValueFromPipeline = false }); pResourceGroupName.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("ResourceGroupName", pResourceGroupName); var pVMScaleSetName = new RuntimeDefinedParameter(); pVMScaleSetName.Name = "VMScaleSetName"; pVMScaleSetName.ParameterType = typeof(string); pVMScaleSetName.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByDynamicParameters", Position = 2, Mandatory = true, ValueFromPipelineByPropertyName = true, ValueFromPipeline = false }); pVMScaleSetName.Attributes.Add(new AliasAttribute("Name")); pVMScaleSetName.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("VMScaleSetName", pVMScaleSetName); var pInstanceIds = new RuntimeDefinedParameter(); pInstanceIds.Name = "InstanceId"; pInstanceIds.ParameterType = typeof(string[]); pInstanceIds.Attributes.Add(new ParameterAttribute { ParameterSetName = "InvokeByDynamicParameters", Position = 3, Mandatory = true, ValueFromPipelineByPropertyName = true, ValueFromPipeline = false }); pInstanceIds.Attributes.Add(new AllowNullAttribute()); dynamicParameters.Add("InstanceId", pInstanceIds); return dynamicParameters; }
/// <summary> /// Adds OAuth authentication parameters for http error action. /// </summary> /// <returns>PowerShell parameters.</returns> internal RuntimeDefinedParameterDictionary AddHttpErrorActionActiveDirectoryOAuthAuthenticationTypeParameters() { var errorActionOAuthTenantAttributes = new Collection<Attribute> { new ParameterAttribute { Mandatory = false, HelpMessage = "The tenant Id.", }, new ValidateNotNullOrEmptyAttribute() }; var errorActionOAuthAudienceAttributes = new Collection<Attribute> { new ParameterAttribute { Mandatory = false, HelpMessage = "The audience.", }, new ValidateNotNullOrEmptyAttribute() }; var errorActionOAuthClientIdAttributes = new Collection<Attribute> { new ParameterAttribute { Mandatory = false, HelpMessage = "The client id.", }, new ValidateNotNullOrEmptyAttribute() }; var errorActionOAuthSecretAttributes = new Collection<Attribute> { new ParameterAttribute { Mandatory = false, HelpMessage = "The secret.", }, new ValidateNotNullOrEmptyAttribute() }; this._errorActionOAuthTenant = new RuntimeDefinedParameter("ErrorActionTenant", typeof(string), errorActionOAuthTenantAttributes); this._errorActionOAuthAudience = new RuntimeDefinedParameter("ErrorActionAudience", typeof(string), errorActionOAuthAudienceAttributes); this._errorActionOAuthClientId = new RuntimeDefinedParameter("ErrorActionClientId", typeof(string), errorActionOAuthClientIdAttributes); this._errorActionOAuthSecret = new RuntimeDefinedParameter("ErrorActionSecret", typeof(string), errorActionOAuthSecretAttributes); var runtimeDefinedParameterDictionary = new RuntimeDefinedParameterDictionary(); runtimeDefinedParameterDictionary.Add("ErrorActionTenant", this._errorActionOAuthTenant); runtimeDefinedParameterDictionary.Add("ErrorActionAudience", this._errorActionOAuthAudience); runtimeDefinedParameterDictionary.Add("ErrorActionClientId", this._errorActionOAuthClientId); runtimeDefinedParameterDictionary.Add("ErrorActionSecret", this._errorActionOAuthSecret); return runtimeDefinedParameterDictionary; }