示例#1
0
 private void GetSplattedVariable(VariableExpressionAst variableAst)
 {
     if (this._context == null)
     {
         throw new PSInvalidOperationException(AutomationExceptions.CantConvertScriptBlockWithNoContext);
     }
     foreach (CommandParameterInternal internal2 in PipelineOps.Splat(this._context.GetVariableValue(variableAst.VariablePath), variableAst.Extent))
     {
         CommandParameter parameter = CommandParameter.FromCommandParameterInternal(internal2);
         this._powershell.AddParameter(parameter.Name, parameter.Value);
     }
 }
示例#2
0
        private void GetSplattedVariable(VariableExpressionAst variableAst)
        {
            if (_context == null)
            {
                throw new PSInvalidOperationException(AutomationExceptions.CantConvertScriptBlockWithNoContext);
            }

            // Process the contents of a splatted variable into the arguments for this
            // command. If the variable contains a hashtable, distribute the key/value pairs
            // If it's an enumerable, then distribute the values as $args and finally
            // if it's a scalar, then the effect is equivalent to $var
            object splattedValue = _context.GetVariableValue(variableAst.VariablePath);

            foreach (var splattedParameter in PipelineOps.Splat(splattedValue, variableAst))
            {
                CommandParameter publicParameter = CommandParameter.FromCommandParameterInternal(splattedParameter);
                _powershell.AddParameter(publicParameter.Name, publicParameter.Value);
            }
        }