/// <summary> /// Verifies the ConfirmImpact level on a cmdlet. /// </summary> /// <param name="cmdlet">The cmdlet to check.</param> /// <param name="confirmImpact">The expected confirm impact.</param> public static void CheckConfirmImpact(Type cmdlet, ConfirmImpact confirmImpact) { object[] cmdletAttributes = cmdlet.GetCustomAttributes(typeof(CmdletAttribute), true); Assert.AreEqual(1, cmdletAttributes.Length); CmdletAttribute attribute = (CmdletAttribute)cmdletAttributes[0]; Assert.AreEqual(confirmImpact, attribute.ConfirmImpact); }
public Cmdlet(Type type) { Type = type; Name = GetName(); OutputTypes = GetOutputTypes(); Operations = GetOperations(); ServiceName = GetServiceName(); ServicePrefix = GetServicePrefix(); DefaultParameterSet = GetDefaultParameterSet(); SupportsShouldProcess = GetSupportsShouldProcess(); ConfirmImpact = GetConfirmImpact(); Parameters = GetParameters(); }
public static void CheckConfirmImpact(Type cmdlet, ConfirmImpact confirmImpact) { object[] cmdletAttributes = cmdlet.GetCustomAttributes(typeof(CmdletAttribute), true); Assert.Single(cmdletAttributes); CmdletAttribute attribute = (CmdletAttribute)cmdletAttributes[0]; if (attribute.SupportsShouldProcess) { Assert.Equal(confirmImpact, attribute.ConfirmImpact); } else { Assert.Equal(ConfirmImpact.None, attribute.ConfirmImpact); } }
internal CommandMetadata( string name, CommandTypes commandType, bool isProxyForCmdlet, string defaultParameterSetName, bool supportsShouldProcess, ConfirmImpact confirmImpact, bool supportsTransactions, Dictionary <string, ParameterMetadata> parameters) { this.commandName = this.wrappedCommand = name; this.wrappedCommandType = commandType; this.wrappedAnyCmdlet = isProxyForCmdlet; this.defaultParameterSetName = defaultParameterSetName; this.supportsShouldProcess = supportsShouldProcess; this.confirmImpact = confirmImpact; this.supportsTransactions = supportsTransactions; this.externalParameterMetadata = parameters; }
public CommandMetadata(CommandMetadata other) { this.commandName = other != null ? other.commandName : throw CommandMetadata.tracer.NewArgumentNullException(nameof(other)); this.confirmImpact = other.confirmImpact; this.defaultParameterSetFlag = other.defaultParameterSetFlag; this.defaultParameterSetName = other.defaultParameterSetName; this.implementsDynamicParameters = other.implementsDynamicParameters; this.supportsShouldProcess = other.supportsShouldProcess; this.supportsTransactions = other.supportsTransactions; this.type = other.type; this.wrappedAnyCmdlet = other.wrappedAnyCmdlet; this.wrappedCommand = other.wrappedCommand; this.wrappedCommandType = other.wrappedCommandType; if (other.externalParameterMetadata == null) { this.externalParameterMetadata = (Dictionary <string, ParameterMetadata>)null; } else { this.externalParameterMetadata = new Dictionary <string, ParameterMetadata>(other.externalParameterMetadata.Count, (IEqualityComparer <string>)StringComparer.OrdinalIgnoreCase); foreach (KeyValuePair <string, ParameterMetadata> keyValuePair in other.externalParameterMetadata) { this.externalParameterMetadata.Add(keyValuePair.Key, new ParameterMetadata(keyValuePair.Value)); } } if (other.otherAttributes == null) { this.otherAttributes = (Collection <Attribute>)null; } else { this.otherAttributes = new Collection <Attribute>((IList <Attribute>) new List <Attribute>(other.otherAttributes.Count)); foreach (Attribute otherAttribute in other.otherAttributes) { this.otherAttributes.Add(otherAttribute); } } this.staticCommandParameterMetadata = (MergedCommandParameterMetadata)null; }
/// <summary> /// Constructor used by implicit remoting /// </summary> internal CommandMetadata( string name, CommandTypes commandType, bool isProxyForCmdlet, string defaultParameterSetName, bool supportsShouldProcess, ConfirmImpact confirmImpact, bool supportsPaging, bool supportsTransactions, bool positionalBinding, Dictionary<string, ParameterMetadata> parameters) { Name = _wrappedCommand = name; _wrappedCommandType = commandType; _wrappedAnyCmdlet = isProxyForCmdlet; _defaultParameterSetName = defaultParameterSetName; SupportsShouldProcess = supportsShouldProcess; SupportsPaging = supportsPaging; ConfirmImpact = confirmImpact; SupportsTransactions = supportsTransactions; PositionalBinding = positionalBinding; this.Parameters = parameters; }
private string Write19_ConfirmImpact(ConfirmImpact v) { switch (v) { case ConfirmImpact.None: return "None"; case ConfirmImpact.Low: return "Low"; case ConfirmImpact.Medium: return "Medium"; case ConfirmImpact.High: return "High"; } long num = (long) v; throw base.CreateInvalidEnumValueException(num.ToString(CultureInfo.InvariantCulture), "Microsoft.PowerShell.Cmdletization.Xml.ConfirmImpact"); }