本文整理汇总了C#中System.Management.Automation.RuntimeDefinedParameter类的典型用法代码示例。如果您正苦于以下问题:C# RuntimeDefinedParameter类的具体用法?C# RuntimeDefinedParameter怎么用?C# RuntimeDefinedParameter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RuntimeDefinedParameter类属于System.Management.Automation命名空间,在下文中一共展示了RuntimeDefinedParameter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateHostedServiceListExtensionsDynamicParameters
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;
}
示例2: CreateExtensionImageRegisterDynamicParameters
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;
}
示例3: AddDynamicParameter
protected static bool AddDynamicParameter(Type type, string name, ref RuntimeDefinedParameterDictionary dic, bool valueFromPipeline)
{
bool paramAdded = false;
if (dic == null || !dic.ContainsKey(name))
{
var attrib = new ParameterAttribute
{
Mandatory = false,
ValueFromPipeline = valueFromPipeline,
};
var param = new RuntimeDefinedParameter
{
IsSet = false,
Name = name,
ParameterType = type
};
param.Attributes.Add(attrib);
if (dic == null)
{
dic = new RuntimeDefinedParameterDictionary();
}
dic.Add(name, param);
paramAdded = true;
}
return paramAdded;
}
示例4: CreateVirtualMachineScaleSetListDynamicParameters
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;
}
示例5: CreateVirtualMachineOSImageGetDetailsDynamicParameters
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;
}
示例6: CreateVirtualMachineScaleSetVMListNextDynamicParameters
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;
}
示例7: GetDefaultScriptParameterValue
internal object GetDefaultScriptParameterValue(RuntimeDefinedParameter parameter, IList implicitUsingParameters = null)
{
object obj2 = parameter.Value;
Compiler.DefaultValueExpressionWrapper wrapper = obj2 as Compiler.DefaultValueExpressionWrapper;
if (wrapper != null)
{
obj2 = wrapper.GetValue(base.Context, this.Script.SessionStateInternal, implicitUsingParameters);
}
return obj2;
}
示例8: CreateVirtualMachineRestartDynamicParameters
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;
}
示例9: CreateVirtualMachineStartRolesDynamicParameters
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;
}
示例10: CompiledCommandParameter
/// <summary>
/// Constructs an instance of the CompiledCommandAttribute using the specified
/// runtime-defined parameter
/// </summary>
///
/// <param name="runtimeDefinedParameter">
/// A runtime defined parameter that contains the definition of the parameter and its
/// metadata.
/// </param>
///
/// <param name="processingDynamicParameters">
/// True if dynamic parameters are being processed, or false otherwise.
/// </param>
///
/// <exception cref="ArgumentNullException">
/// If <paramref name="runtimeDefinedParameter"/> is null.
/// </exception>
///
/// <exception cref="MetadataException">
/// If the parameter has more than one <see cref="ParameterAttribute">ParameterAttribute</see>
/// that defines the same parameter-set name.
/// </exception>
///
internal CompiledCommandParameter(RuntimeDefinedParameter runtimeDefinedParameter, bool processingDynamicParameters)
{
if (runtimeDefinedParameter == null)
{
throw PSTraceSource.NewArgumentNullException("runtimeDefinedParameter");
}
this.Name = runtimeDefinedParameter.Name;
this.Type = runtimeDefinedParameter.ParameterType;
this.IsDynamic = processingDynamicParameters;
this.CollectionTypeInformation = new ParameterCollectionTypeInformation(runtimeDefinedParameter.ParameterType);
this.CompiledAttributes = new Collection<Attribute>();
this.ParameterSetData = new Dictionary<string, ParameterSetSpecificMetadata>(StringComparer.OrdinalIgnoreCase);
Collection<ValidateArgumentsAttribute> validationAttributes = null;
Collection<ArgumentTransformationAttribute> argTransformationAttributes = null;
string[] aliases = null;
// First, process attributes that aren't type conversions
foreach (Attribute attribute in runtimeDefinedParameter.Attributes)
{
if (!(attribute is ArgumentTypeConverterAttribute))
{
ProcessAttribute(runtimeDefinedParameter.Name, attribute, ref validationAttributes, ref argTransformationAttributes, ref aliases);
}
}
// If this is a PSCredential type and they haven't added any argument transformation attributes,
// add one for credential transformation
if ((this.Type == typeof(PSCredential)) && argTransformationAttributes == null)
{
ProcessAttribute(runtimeDefinedParameter.Name, new CredentialAttribute(), ref validationAttributes, ref argTransformationAttributes, ref aliases);
}
// Now process type converters
foreach (ArgumentTypeConverterAttribute attribute in runtimeDefinedParameter.Attributes.OfType<ArgumentTypeConverterAttribute>())
{
ProcessAttribute(runtimeDefinedParameter.Name, attribute, ref validationAttributes, ref argTransformationAttributes, ref aliases);
}
this.ValidationAttributes = validationAttributes == null
? Utils.EmptyArray<ValidateArgumentsAttribute>()
: validationAttributes.ToArray();
this.ArgumentTransformationAttributes = argTransformationAttributes == null
? Utils.EmptyArray<ArgumentTransformationAttribute>()
: argTransformationAttributes.ToArray();
this.Aliases = aliases == null
? Utils.EmptyArray<string>()
: aliases.ToArray();
}
示例11: CreateContainerServiceCreateOrUpdateDynamicParameters
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;
}
示例12: CreateExtensionImageUnregisterDynamicParameters
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;
}
示例13: CreateOperatingSystemListDynamicParameters
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;
}
示例14: CompiledCommandParameter
internal CompiledCommandParameter(RuntimeDefinedParameter runtimeDefinedParameter, bool processingDynamicParameters)
{
this.name = string.Empty;
this.typeName = string.Empty;
this.argumentTransformationAttributes = new Collection<ArgumentTransformationAttribute>();
this.validationAttributes = new Collection<ValidateArgumentsAttribute>();
this.aliases = new Collection<string>();
if (runtimeDefinedParameter == null)
{
throw PSTraceSource.NewArgumentNullException("runtimeDefinedParameter");
}
this.name = runtimeDefinedParameter.Name;
this.type = runtimeDefinedParameter.ParameterType;
this.isDynamic = processingDynamicParameters;
this.collectionTypeInformation = new ParameterCollectionTypeInformation(runtimeDefinedParameter.ParameterType);
this.ConstructCompiledAttributesUsingRuntimeDefinedParameter(runtimeDefinedParameter);
}
示例15: CreateVirtualMachineExtensionListVersionsDynamicParameters
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;
}