Exemple #1
0
 public static string GetParamBlock(CommandMetadata commandMetadata)
 {
     if (commandMetadata == null)
     {
         throw PSTraceSource.NewArgumentNullException("commandMetaData");
     }
     return(commandMetadata.GetParamBlock());
 }
Exemple #2
0
 public static string GetParamBlock(CommandMetadata commandMetadata) => commandMetadata != null?commandMetadata.GetParamBlock() : throw ProxyCommand.tracer.NewArgumentNullException("commandMetaData");
 private void GenerateCommandProxy(TextWriter writer, CommandMetadata commandMetadata)
 {
     if (writer == null)
     {
         throw PSTraceSource.NewArgumentNullException("writer");
     }
     string str = CommandMetadata.EscapeSingleQuotedString(commandMetadata.Name);
     string str2 = this.EscapeFunctionNameForRemoteHelp(commandMetadata.Name);
     object[] arg = new object[9];
     arg[0] = str;
     arg[1] = str2;
     arg[2] = commandMetadata.GetDecl();
     arg[3] = commandMetadata.GetParamBlock();
     arg[5] = commandMetadata.WrappedCommandType;
     arg[6] = ProxyCommand.GetProcess(commandMetadata);
     arg[7] = ProxyCommand.GetEnd(commandMetadata);
     arg[8] = commandMetadata.WrappedAnyCmdlet;
     writer.Write("\r\n& $script:SetItem 'function:script:{0}' `\r\n{{\r\n    param(\r\n    {3})\r\n\r\n    Begin {{\r\n        try {{\r\n            $positionalArguments = & $script:NewObject collections.arraylist\r\n            foreach ($parameterName in $PSBoundParameters.BoundPositionally)\r\n            {{\r\n                $null = $positionalArguments.Add( $PSBoundParameters[$parameterName] )\r\n                $null = $PSBoundParameters.Remove($parameterName)\r\n            }}\r\n            $positionalArguments.AddRange($args)\r\n\r\n            $clientSideParameters = Get-PSImplicitRemotingClientSideParameters $PSBoundParameters ${8}\r\n\r\n            $scriptCmd = {{ & $script:InvokeCommand `\r\n                            @clientSideParameters `\r\n                            -HideComputerName `\r\n                            -Session (Get-PSImplicitRemotingSession -CommandName '{0}') `\r\n                            -Arg ('{0}', $PSBoundParameters, $positionalArguments) `\r\n                            -Script {{ param($name, $boundParams, $unboundParams) & $name @boundParams @unboundParams }} `\r\n                         }}\r\n\r\n            $steppablePipeline = $scriptCmd.GetSteppablePipeline($myInvocation.CommandOrigin)\r\n            $steppablePipeline.Begin($myInvocation.ExpectingInput, $ExecutionContext)\r\n        }} catch {{\r\n            throw\r\n        }}\r\n    }}\r\n    Process {{ {6} }}\r\n    End {{ {7} }}\r\n\r\n    # .ForwardHelpTargetName {1}\r\n    # .ForwardHelpCategory {5}\r\n    # .RemoteHelpRunspace PSSession\r\n}}\r\n        ", arg);
 }