コード例 #1
0
 private void GenerateTopComment(TextWriter writer)
 {
     writer.Write("\r\n<#\r\n # {0}\r\n # {1}\r\n # {2}\r\n # {3}\r\n #>\r\n        ", new object[] { CommandMetadata.EscapeBlockComment(StringUtil.Format(ImplicitRemotingStrings.ModuleHeaderTitle, new object[0])), CommandMetadata.EscapeBlockComment(StringUtil.Format(ImplicitRemotingStrings.ModuleHeaderDate, DateTime.Now.ToString(CultureInfo.CurrentCulture))), CommandMetadata.EscapeBlockComment(StringUtil.Format(ImplicitRemotingStrings.ModuleHeaderCommand, this.invocationInfo.MyCommand.Name)), CommandMetadata.EscapeBlockComment(StringUtil.Format(ImplicitRemotingStrings.ModuleHeaderCommandLine, this.invocationInfo.Line)) });
 }
コード例 #2
0
        private void GenerateModuleHeader(TextWriter writer)
        {
            if (writer == null)
            {
                throw PSTraceSource.NewArgumentNullException("writer");
            }
            string str = "[" + typeof(ExportPSSessionCommand).AssemblyQualifiedName + "]::VersionOfScriptGenerator";

            this.GenerateTopComment(writer);
            writer.Write("\r\nparam(\r\n    <# {0} #>    \r\n    [System.Management.Automation.Runspaces.PSSession] $PSSessionOverride,\r\n    [System.Management.Automation.Remoting.PSSessionOption] $PSSessionOptionOverride\r\n)\r\n\r\n$script:__psImplicitRemoting_versionOfScriptGenerator = {1}\r\nif ($script:__psImplicitRemoting_versionOfScriptGenerator.Major -ne {2})\r\n{{\r\n    throw '{3}'\r\n}}\r\n\r\n\r\n$script:WriteHost = $executionContext.InvokeCommand.GetCommand('Write-Host', [System.Management.Automation.CommandTypes]::Cmdlet)\r\n$script:WriteWarning = $executionContext.InvokeCommand.GetCommand('Write-Warning', [System.Management.Automation.CommandTypes]::Cmdlet)\r\n$script:GetPSSession = $executionContext.InvokeCommand.GetCommand('Get-PSSession', [System.Management.Automation.CommandTypes]::Cmdlet)\r\n$script:NewPSSession = $executionContext.InvokeCommand.GetCommand('New-PSSession', [System.Management.Automation.CommandTypes]::Cmdlet)\r\n$script:ConnectPSSession = $executionContext.InvokeCommand.GetCommand('Connect-PSSession', [System.Management.Automation.CommandTypes]::Cmdlet)\r\n$script:NewObject = $executionContext.InvokeCommand.GetCommand('New-Object', [System.Management.Automation.CommandTypes]::Cmdlet)\r\n$script:RemovePSSession = $executionContext.InvokeCommand.GetCommand('Remove-PSSession', [System.Management.Automation.CommandTypes]::Cmdlet)\r\n$script:InvokeCommand = $executionContext.InvokeCommand.GetCommand('Invoke-Command', [System.Management.Automation.CommandTypes]::Cmdlet)\r\n$script:SetItem = $executionContext.InvokeCommand.GetCommand('Set-Item', [System.Management.Automation.CommandTypes]::Cmdlet)\r\n$script:ImportCliXml = $executionContext.InvokeCommand.GetCommand('Import-CliXml', [System.Management.Automation.CommandTypes]::Cmdlet)\r\n$script:NewPSSessionOption = $executionContext.InvokeCommand.GetCommand('New-PSSessionOption', [System.Management.Automation.CommandTypes]::Cmdlet)\r\n$script:JoinPath = $executionContext.InvokeCommand.GetCommand('Join-Path', [System.Management.Automation.CommandTypes]::Cmdlet)\r\n$script:ExportModuleMember = $executionContext.InvokeCommand.GetCommand('Export-ModuleMember', [System.Management.Automation.CommandTypes]::Cmdlet)\r\n$script:SetAlias = $executionContext.InvokeCommand.GetCommand('Set-Alias', [System.Management.Automation.CommandTypes]::Cmdlet)\r\n\r\n$script:MyModule = $MyInvocation.MyCommand.ScriptBlock.Module\r\n        ", new object[] { CommandMetadata.EscapeBlockComment(StringUtil.Format(ImplicitRemotingStrings.ModuleHeaderRunspaceOverrideParameter, new object[0])), str, VersionOfScriptWriter, CommandMetadata.EscapeSingleQuotedString(string.Format(null, PathUtilsStrings.ExportPSSession_ScriptGeneratorVersionMismatch, new object[] { "Export-PSSession" })) });
        }