internal CmdletParameterBinderController(Cmdlet cmdlet, CommandMetadata commandMetadata, ParameterBinderBase parameterBinder) : base(cmdlet.MyInvocation, cmdlet.Context, parameterBinder) { this._warningSet = new HashSet<string>(); this._useDefaultParameterBinding = true; this._delayBindScriptBlocks = new Dictionary<MergedCompiledCommandParameter, DelayedScriptBlockArgument>(); this._defaultParameterValues = new Dictionary<string, CommandParameterInternal>(StringComparer.OrdinalIgnoreCase); if (cmdlet == null) { throw PSTraceSource.NewArgumentNullException("cmdlet"); } if (commandMetadata == null) { throw PSTraceSource.NewArgumentNullException("commandMetadata"); } this.Command = cmdlet; this._commandRuntime = (MshCommandRuntime)cmdlet.CommandRuntime; this._commandMetadata = commandMetadata; if (commandMetadata.ImplementsDynamicParameters) { base.UnboundParameters = base.BindableParameters.ReplaceMetadata(commandMetadata.StaticCommandParameterMetadata); base.BindableParameters.GenerateParameterSetMappingFromMetadata(commandMetadata.DefaultParameterSetName); } else { base._bindableParameters = commandMetadata.StaticCommandParameterMetadata; base.UnboundParameters = new List<MergedCompiledCommandParameter>(base._bindableParameters.BindableParameters.Values); } }
internal ShouldProcessParameters(MshCommandRuntime commandRuntime) { if (commandRuntime == null) { throw PSTraceSource.NewArgumentNullException("commandRuntime"); } this.commandRuntime = commandRuntime; }
internal PagingParameters(MshCommandRuntime commandRuntime) { if (commandRuntime == null) { throw PSTraceSource.NewArgumentNullException("commandRuntime"); } commandRuntime.PagingParameters = this; }
internal CommandInvocationIntrinsics(System.Management.Automation.ExecutionContext context, PSCmdlet cmdlet) { this._context = context; if (cmdlet != null) { this._cmdlet = cmdlet; this.commandRuntime = cmdlet.CommandRuntime as MshCommandRuntime; } }
protected override void BeginProcessing() { this._commandRuntime = (MshCommandRuntime) base.commandRuntime; this._functionContext._outputPipe = this._commandRuntime.OutputPipe; this.SetPreferenceVariables(); if (this._scriptBlock.HasBeginBlock) { this.RunClause(this._runOptimized ? this._scriptBlock.BeginBlock : this._scriptBlock.UnoptimizedBeginBlock, AutomationNull.Value, this._input); } }
public object GetDynamicParameters() { _commandRuntime = (MshCommandRuntime)commandRuntime; if (_scriptBlock.HasDynamicParameters) { var resultList = new List<object>(); Diagnostics.Assert(_functionContext._outputPipe == null, "Output pipe should not be set yet."); _functionContext._outputPipe = new Pipe(resultList); RunClause(_runOptimized ? _scriptBlock.DynamicParamBlock : _scriptBlock.UnoptimizedDynamicParamBlock, AutomationNull.Value, AutomationNull.Value); if (resultList.Count > 1) { throw PSTraceSource.NewInvalidOperationException(AutomationExceptions.DynamicParametersWrongType, PSObject.ToStringParser(this.Context, resultList)); } return resultList.Count == 0 ? null : PSObject.Base(resultList[0]); } return null; }
protected override void BeginProcessing() { // commandRuntime and the execution context are set here and in GetDynamicParameters. GetDynamicParameters isn't // called unless the scriptblock has a dynamicparam block, so we must set these values in both places. It'd // be cleaner to set in the constructor, but neither the commandRuntime nor the context are set when being constructed. _commandRuntime = (MshCommandRuntime)commandRuntime; // We don't set the output pipe until after GetDynamicParameters because dynamic parameters aren't written to the // command processors pipe, but once we enter begin, we will write to the default pipe. _functionContext._outputPipe = _commandRuntime.OutputPipe; SetPreferenceVariables(); if (_scriptBlock.HasBeginBlock) { RunClause(_runOptimized ? _scriptBlock.BeginBlock : _scriptBlock.UnoptimizedBeginBlock, AutomationNull.Value, _input); } }
internal CommandInvocationIntrinsics(ExecutionContext context, PSCmdlet cmdlet) { _context = context; if (cmdlet != null) { _cmdlet = cmdlet; _commandRuntime = cmdlet.CommandRuntime as MshCommandRuntime; } }
private Pipe GetRedirectionPipe(PipelineResultTypes toType, MshCommandRuntime mcr) { if (toType == PipelineResultTypes.Output) { return mcr.OutputPipe; } return new Pipe { NullPipe = true }; }
internal TransactionParameters(MshCommandRuntime commandRuntime) { this.commandRuntime = commandRuntime; }
internal void SetMergeFromRuntime(MshCommandRuntime fromRuntime) { this.ErrorMergeTo = fromRuntime.ErrorMergeTo; if (fromRuntime.WarningOutputPipe != null) { this.WarningOutputPipe = fromRuntime.WarningOutputPipe; } if (fromRuntime.VerboseOutputPipe != null) { this.VerboseOutputPipe = fromRuntime.VerboseOutputPipe; } if (fromRuntime.DebugOutputPipe != null) { this.DebugOutputPipe = fromRuntime.DebugOutputPipe; } }
public object GetDynamicParameters() { this._commandRuntime = (MshCommandRuntime) base.commandRuntime; if (this._scriptBlock.HasDynamicParameters) { ArrayList resultList = new ArrayList(); this._functionContext._outputPipe = new Pipe(resultList); this.RunClause(this._runOptimized ? this._scriptBlock.DynamicParamBlock : this._scriptBlock.UnoptimizedDynamicParamBlock, AutomationNull.Value, AutomationNull.Value); if (resultList.Count > 1) { throw PSTraceSource.NewInvalidOperationException("AutomationExceptions", "DynamicParametersWrongType", new object[] { PSObject.ToStringParser(base.Context, resultList) }); } if (resultList.Count != 0) { return PSObject.Base(resultList[0]); } } return null; }