private PopPipeline ( ) : System.Management.Automation.Runspaces.Pipeline | ||
리턴 | System.Management.Automation.Runspaces.Pipeline |
internal override void Execute(ExecutionContext context, ICommandRuntime commandRuntime) { ExecutionContext nestedContext = context.CreateNestedContext(); if (lValue is VariableNode) { VariableNode varNode = (VariableNode)lValue; if (! (context.CurrentRunspace is LocalRunspace)) throw new InvalidOperationException("Invalid context"); // MUST: fix this with the commandRuntime Pipeline pipeline = context.CurrentRunspace.CreateNestedPipeline(); context.PushPipeline(pipeline); try { Command cmd = new Command("Set-Variable"); cmd.Parameters.Add("Name", new string[] { varNode.Text }); cmd.Parameters.Add("Value", rValue.GetValue(context)); // TODO: implement command invoke pipeline.Commands.Add(cmd); pipeline.Invoke(); } catch (Exception) { throw; } finally { context.PopPipeline(); } } }
internal override void Execute(Pash.Implementation.ExecutionContext context, ICommandRuntime commandRuntime) { ExecutionContext nestedContext = context.CreateNestedContext(); if (!(context.CurrentRunspace is LocalRunspace)) { throw new InvalidOperationException("Invalid context"); } // MUST: fix this with the commandRuntime Pipeline pipeline = context.CurrentRunspace.CreateNestedPipeline(); context.PushPipeline(pipeline); try { Command cmd = new Command("Get-Variable"); cmd.Parameters.Add("Name", new string[] { Text }); // TODO: implement command invoke pipeline.Commands.Add(cmd); commandRuntime.WriteObject(pipeline.Invoke(), true); //context.outputStreamWriter.Write(pipeline.Invoke(), true); } catch (Exception) { throw; } finally { context.PopPipeline(); } }
internal override object GetValue(ExecutionContext context) { if (! _bExecuted) { if (! (context.CurrentRunspace is LocalRunspace)) throw new InvalidOperationException(string.Format("Command \"{0}\" was not found.", Text)); CommandManager cmdMgr = ((LocalRunspace) context.CurrentRunspace).CommandManager; CommandInfo cmdInfo = cmdMgr.FindCommand(Text); if (cmdInfo == null) throw new InvalidOperationException(string.Format("Command \"{0}\" was not found.", Text)); // MUST: fix this with the commandRuntime Pipeline pipeline = context.CurrentRunspace.CreateNestedPipeline(); // Fill the pipeline with input data pipeline.Input.Write(context.inputStreamReader); context.PushPipeline(pipeline); try { // TODO: implement command invoke pipeline.Commands.Add(Text); _results = pipeline.Invoke(); } catch (Exception) { throw; } finally { context.PopPipeline(); } _bExecuted = true; } return _results; }
internal override object GetValue(ExecutionContext context) { Pipeline pipeline = context.CurrentRunspace.CreateNestedPipeline(); context.PushPipeline(pipeline); Collection<PSObject> results = nodeValue.GetValue(context) as Collection<PSObject>; context.PopPipeline(); if (results.Count == 0) return null; if (results.Count == 1) return results[0]; // TODO: make sure that the array.ToString calls the ToString on each PSObject PSObject[] array = new PSObject[results.Count]; int index = 0; foreach (PSObject psObject in results) { array[index++] = psObject; } return array; }
internal override void Execute(ExecutionContext context, ICommandRuntime commandRuntime) { if (!(context.CurrentRunspace is LocalRunspace)) throw new InvalidOperationException(string.Format("Command \"{0}\" was not found.", CmdletName)); CommandManager cmdMgr = ((LocalRunspace)context.CurrentRunspace).CommandManager; CommandInfo cmdInfo = cmdMgr.FindCommand(CmdletName); if (cmdInfo == null) throw new InvalidOperationException(string.Format("Command \"{0}\" was not found.", CmdletName)); // MUST: fix this with the commandRuntime Pipeline pipeline = context.CurrentRunspace.CreateNestedPipeline(); context.PushPipeline(pipeline); try { // TODO: implement command invoke Command command = new Command(CmdletName); foreach (string param in Params.Params) { command.Parameters.Add(null, param); } pipeline.Commands.Add(command); _results = pipeline.Invoke(); commandRuntime.WriteObject(_results, true); } catch (Exception) { throw; } finally { context.PopPipeline(); } }