Пример #1
0
        /// <summary>
        /// Formats the input objects using out-string. Output of out-string
        /// is given as input to native command processor.
        /// This method is to be called from the pipeline thread and not from the
        /// thread which writes input in to process.
        /// </summary>
        private void ConvertToString()
        {
            Dbg.Assert(_inputFormat == NativeCommandIOFormat.Text, "InputFormat should be Text");

            PipelineProcessor p = new PipelineProcessor();
            p.Add(_command.Context.CreateCommand("out-string", false));
            object[] result = (object[])p.SynchronousExecuteEnumerate(_inputList.ToArray());
            _inputList = new ArrayList(result);
        }
Пример #2
0
        internal static void InvokePipeline (object input, bool ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)
		{
			PipelineProcessor pipelineProcessor = new PipelineProcessor ();
			System.Management.Automation.ExecutionContext context = funcContext._executionContext;
			Pipe pipe = funcContext._outputPipe;
			try {
				if (context.Events != null) {
					context.Events.ProcessPendingActions ();
				}
				if ((input == AutomationNull.Value) && !ignoreInput) {
					AddNoopCommandProcessor (pipelineProcessor, context);
				}
				CommandProcessorBase commandProcessor = null;
				CommandRedirection[] redirections = null;
				for (int i = 0; i < pipeElements.Length; i++) {
					redirections = (commandRedirections != null) ? commandRedirections [i] : null;
					commandProcessor = AddCommand (pipelineProcessor, pipeElements [i], pipeElementAsts [i], redirections, context);
				}
				if ((commandProcessor != null) && !commandProcessor.CommandRuntime.OutputPipe.IsRedirected) {
					pipelineProcessor.LinkPipelineSuccessOutput (pipe ?? new Pipe (new ArrayList ()));
					if (redirections != null) {
						foreach (CommandRedirection redirection in redirections) {
							if (redirection is MergingRedirection) {
								redirection.Bind (pipelineProcessor, commandProcessor, context);
							}
						}
					}
				}
				context.PushPipelineProcessor (pipelineProcessor);
				try {
					pipelineProcessor.SynchronousExecuteEnumerate (input, null, true);
				} finally {
					context.PopPipelineProcessor (false);
				}
			}
            finally
            {
                context.QuestionMarkVariableValue = !pipelineProcessor.ExecutionFailed;
                pipelineProcessor.Dispose();
            }
        }