コード例 #1
0
        private MergedCommandParameterMetadata GetMergedCommandParameterMetdata()
        {
            if (this._context == null)
            {
                return(null);
            }
            IScriptCommandInfo scriptCommandInfo = this as IScriptCommandInfo;
            CommandProcessor   commandProcessor  = (scriptCommandInfo != null) ? new CommandProcessor(scriptCommandInfo, this._context, true, false, scriptCommandInfo.ScriptBlock.SessionStateInternal ?? this.Context.EngineSessionState) : new CommandProcessor((CmdletInfo)this, this._context);

            ParameterBinderController.AddArgumentsToCommandProcessor(commandProcessor, this.Arguments);
            CommandProcessorBase currentCommandProcessor = this.Context.CurrentCommandProcessor;

            try
            {
                this.Context.CurrentCommandProcessor = commandProcessor;
                commandProcessor.SetCurrentScopeToExecutionScope();
                commandProcessor.CmdletParameterBinderController.BindCommandLineParametersNoValidation(commandProcessor.arguments);
            }
            catch (ParameterBindingException)
            {
                if (commandProcessor.arguments.Count > 0)
                {
                    throw;
                }
            }
            finally
            {
                this.Context.CurrentCommandProcessor = currentCommandProcessor;
                commandProcessor.RestorePreviousScope();
            }
            return(commandProcessor.CmdletParameterBinderController.BindableParameters);
        }