private void ProcessParameterAttribute(string parameterName, ParameterAttribute parameter) { if (this._parameterSetData.ContainsKey(parameter.ParameterSetName)) { System.Management.Automation.MetadataException exception = new System.Management.Automation.MetadataException("ParameterDeclaredInParameterSetMultipleTimes", null, DiscoveryExceptions.ParameterDeclaredInParameterSetMultipleTimes, new object[] { parameterName, parameter.ParameterSetName }); throw exception; } if (parameter.ValueFromPipeline || parameter.ValueFromPipelineByPropertyName) { this._isPipelineParameterInSomeParameterSet = true; } if (parameter.Mandatory) { this._isMandatoryInSomeParameterSet = true; } ParameterSetSpecificMetadata metadata = new ParameterSetSpecificMetadata(parameter); this._parameterSetData.Add(parameter.ParameterSetName, metadata); }
internal Collection <MergedCompiledCommandParameter> AddMetadataForBinder(InternalParameterMetadata parameterMetadata, ParameterBinderAssociation binderAssociation) { if (parameterMetadata == null) { throw PSTraceSource.NewArgumentNullException("parameterMetadata"); } Collection <MergedCompiledCommandParameter> collection = new Collection <MergedCompiledCommandParameter>(); foreach (KeyValuePair <string, CompiledCommandParameter> pair in parameterMetadata.BindableParameters) { if (this.bindableParameters.ContainsKey(pair.Key)) { System.Management.Automation.MetadataException exception = new System.Management.Automation.MetadataException("ParameterNameAlreadyExistsForCommand", null, Metadata.ParameterNameAlreadyExistsForCommand, new object[] { pair.Key }); throw exception; } if (this.aliasedParameters.ContainsKey(pair.Key)) { System.Management.Automation.MetadataException exception2 = new System.Management.Automation.MetadataException("ParameterNameConflictsWithAlias", null, Metadata.ParameterNameConflictsWithAlias, new object[] { pair.Key, RetrieveParameterNameForAlias(pair.Key, this.aliasedParameters) }); throw exception2; } MergedCompiledCommandParameter parameter = new MergedCompiledCommandParameter(pair.Value, binderAssociation); this.bindableParameters.Add(pair.Key, parameter); collection.Add(parameter); foreach (string str in pair.Value.Aliases) { if (this.aliasedParameters.ContainsKey(str)) { System.Management.Automation.MetadataException exception3 = new System.Management.Automation.MetadataException("AliasParameterNameAlreadyExistsForCommand", null, Metadata.AliasParameterNameAlreadyExistsForCommand, new object[] { str }); throw exception3; } if (this.bindableParameters.ContainsKey(str)) { System.Management.Automation.MetadataException exception4 = new System.Management.Automation.MetadataException("ParameterNameConflictsWithAlias", null, Metadata.ParameterNameConflictsWithAlias, new object[] { RetrieveParameterNameForAlias(str, this.bindableParameters), pair.Value.Name }); throw exception4; } this.aliasedParameters.Add(str, parameter); } } return(collection); }
internal Collection<MergedCompiledCommandParameter> AddMetadataForBinder(InternalParameterMetadata parameterMetadata, ParameterBinderAssociation binderAssociation) { if (parameterMetadata == null) { throw PSTraceSource.NewArgumentNullException("parameterMetadata"); } Collection<MergedCompiledCommandParameter> collection = new Collection<MergedCompiledCommandParameter>(); foreach (KeyValuePair<string, CompiledCommandParameter> pair in parameterMetadata.BindableParameters) { if (this.bindableParameters.ContainsKey(pair.Key)) { System.Management.Automation.MetadataException exception = new System.Management.Automation.MetadataException("ParameterNameAlreadyExistsForCommand", null, Metadata.ParameterNameAlreadyExistsForCommand, new object[] { pair.Key }); throw exception; } if (this.aliasedParameters.ContainsKey(pair.Key)) { System.Management.Automation.MetadataException exception2 = new System.Management.Automation.MetadataException("ParameterNameConflictsWithAlias", null, Metadata.ParameterNameConflictsWithAlias, new object[] { pair.Key, RetrieveParameterNameForAlias(pair.Key, this.aliasedParameters) }); throw exception2; } MergedCompiledCommandParameter parameter = new MergedCompiledCommandParameter(pair.Value, binderAssociation); this.bindableParameters.Add(pair.Key, parameter); collection.Add(parameter); foreach (string str in pair.Value.Aliases) { if (this.aliasedParameters.ContainsKey(str)) { System.Management.Automation.MetadataException exception3 = new System.Management.Automation.MetadataException("AliasParameterNameAlreadyExistsForCommand", null, Metadata.AliasParameterNameAlreadyExistsForCommand, new object[] { str }); throw exception3; } if (this.bindableParameters.ContainsKey(str)) { System.Management.Automation.MetadataException exception4 = new System.Management.Automation.MetadataException("ParameterNameConflictsWithAlias", null, Metadata.ParameterNameConflictsWithAlias, new object[] { RetrieveParameterNameForAlias(str, this.bindableParameters), pair.Value.Name }); throw exception4; } this.aliasedParameters.Add(str, parameter); } } return collection; }