Pash.Implementation.ExecutionContext.SetVariable C# (CSharp) Method

SetVariable() private method

private SetVariable ( string name, object value ) : void
name string
value object
return void
        internal void SetVariable(string name, object value)
        {
            if (string.IsNullOrEmpty(name))
                throw new NullReferenceException("Variable name can't be empty.");

            this.SessionState.PSVariable.Set(name, value);
        }

Usage Example

Ejemplo n.º 1
0
 /// <summary>
 /// In a script block, we only provide the pipeline as the automatic $input variable, but call it only once
 /// </summary>
 public override void ProcessRecords()
 {
     // TODO: provide the automatic $input variable
     // TODO: currently we don't support "cmdlet scripts", i.e. functions that behave like cmdlets.
     // TODO: Investigate the usage of different function blocks properly before implementing them
     //set the execution context of the runspace to the new context for execution in it
     SwitchToOwnScope();
     try
     {
         _scriptBlockInfo.ScriptBlock.Ast.Visit(new ExecutionVisitor(ExecutionContext, CommandRuntime, false));
     }
     catch (ExitException e)
     {
         if (_fromFile)
         {
             _exitCode = e.ExitCode;
             ExecutionContext.SetVariable("global:LASTEXITCODE", e.ExitCode);
         }
         else
         {
             throw;
         }
     }
     finally //make sure we switch back to the original execution context, no matter what happened
     {
         RestoreOriginalScope();
     }
 }
All Usage Examples Of Pash.Implementation.ExecutionContext::SetVariable