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;
 }
 /// <summary>
 /// Constructs an association between the CompiledCommandParameter and the
 /// binder that should be used to bind it.
 /// </summary>
 /// 
 /// <param name="parameter">
 /// The metadata for a parameter.
 /// </param>
 /// 
 /// <param name="binderAssociation">
 /// The type of binder that should be used to bind the parameter.
 /// </param>
 internal MergedCompiledCommandParameter(
         CompiledCommandParameter parameter,
         ParameterBinderAssociation binderAssociation)
 {
     Diagnostics.Assert(parameter != null, "caller to verify parameter is not null");
     this.Parameter = parameter;
     this.BinderAssociation = binderAssociation;
 }
        } // ReplaceMetadata

        /// <summary>
        /// Merges the specified metadata with the other metadata already defined
        /// in this object.
        /// </summary>
        /// 
        /// <param name="parameterMetadata">
        /// The compiled metadata for the type to be merged.
        /// </param>
        /// 
        /// <param name="binderAssociation">
        /// The type of binder that the CommandProcessor will use to bind
        /// the parameters for <paramref name="parameterMetadata"/>
        /// </param>
        /// 
        /// <returns>
        /// A collection of the merged parameter metadata that was added.
        /// </returns>
        /// 
        /// <exception cref="MetadataException">
        /// If a parameter name or alias described in the <paramref name="parameterMetadata"/> already
        /// exists.
        /// </exception>
        /// 
        internal Collection<MergedCompiledCommandParameter> AddMetadataForBinder(
            InternalParameterMetadata parameterMetadata,
            ParameterBinderAssociation binderAssociation)
        {
            if (parameterMetadata == null)
            {
                throw PSTraceSource.NewArgumentNullException("parameterMetadata");
            }

            Collection<MergedCompiledCommandParameter> result =
                new Collection<MergedCompiledCommandParameter>();

            // Merge in the bindable parameters

            foreach (KeyValuePair<string, CompiledCommandParameter> bindableParameter in parameterMetadata.BindableParameters)
            {
                if (_bindableParameters.ContainsKey(bindableParameter.Key))
                {
                    MetadataException exception =
                        new MetadataException(
                            "ParameterNameAlreadyExistsForCommand",
                            null,
                            Metadata.ParameterNameAlreadyExistsForCommand,
                            bindableParameter.Key);
                    throw exception;
                }

                // NTRAID#Windows Out Of Band Releases-926371-2005/12/27-JonN
                if (_aliasedParameters.ContainsKey(bindableParameter.Key))
                {
                    MetadataException exception =
                        new MetadataException(
                            "ParameterNameConflictsWithAlias",
                            null,
                            Metadata.ParameterNameConflictsWithAlias,
                            bindableParameter.Key,
                            RetrieveParameterNameForAlias(bindableParameter.Key, _aliasedParameters));
                    throw exception;
                }

                MergedCompiledCommandParameter mergedParameter =
                    new MergedCompiledCommandParameter(bindableParameter.Value, binderAssociation);

                _bindableParameters.Add(bindableParameter.Key, mergedParameter);
                result.Add(mergedParameter);

                // Merge in the aliases

                foreach (string aliasName in bindableParameter.Value.Aliases)
                {
                    if (_aliasedParameters.ContainsKey(aliasName))
                    {
                        MetadataException exception =
                            new MetadataException(
                                "AliasParameterNameAlreadyExistsForCommand",
                                null,
                                Metadata.AliasParameterNameAlreadyExistsForCommand,
                                aliasName);
                        throw exception;
                    }

                    // NTRAID#Windows Out Of Band Releases-926371-2005/12/27-JonN
                    if (_bindableParameters.ContainsKey(aliasName))
                    {
                        MetadataException exception =
                            new MetadataException(
                                "ParameterNameConflictsWithAlias",
                                null,
                                Metadata.ParameterNameConflictsWithAlias,
                                RetrieveParameterNameForAlias(aliasName, _bindableParameters),
                                bindableParameter.Value.Name);
                        throw exception;
                    }

                    _aliasedParameters.Add(aliasName, mergedParameter);
                }
            }
            return result;
        }
 internal MergedCompiledCommandParameter(CompiledCommandParameter parameter, ParameterBinderAssociation binderAssociation)
 {
     this.Parameter = parameter;
     this.BinderAssociation = binderAssociation;
 }