Windows-powershell / PowerShell-master /src /Microsoft.PowerShell.Commands.Utility /commands /utility /FormatAndOutput /out-printer /Out-Printer.cs
| // Copyright (c) Microsoft Corporation. | |
| // Licensed under the MIT License. | |
| using System.Management.Automation; | |
| using Microsoft.PowerShell.Commands.Internal.Format; | |
| namespace Microsoft.PowerShell.Commands | |
| { | |
| /// <summary> | |
| /// Implementation for the out-printer command. | |
| /// </summary> | |
| [] | |
| public class OutPrinterCommand : FrontEndCommandBase | |
| { | |
| /// <summary> | |
| /// Initializes a new instance of the <see cref="OutPrinterCommand"/> class | |
| /// and sets the inner command. | |
| /// </summary> | |
| public OutPrinterCommand() | |
| { | |
| this.implementation = new OutputManagerInner(); | |
| } | |
| /// <summary> | |
| /// Optional name of the printer to print to. | |
| /// The alias allows "lp -P printer". | |
| /// </summary> | |
| [] | |
| [] | |
| public string Name | |
| { | |
| get { return _printerName; } | |
| set { _printerName = value; } | |
| } | |
| private string _printerName; | |
| /// <summary> | |
| /// Read command line parameters. | |
| /// </summary> | |
| protected override void BeginProcessing() | |
| { | |
| // set up the Screen Host interface | |
| OutputManagerInner outInner = (OutputManagerInner)this.implementation; | |
| outInner.LineOutput = InstantiateLineOutputInterface(); | |
| // finally call the base class for general hookup | |
| base.BeginProcessing(); | |
| } | |
| /// <summary> | |
| /// One-time initialization: acquire a screen host interface by creating one on top of a memory buffer. | |
| /// </summary> | |
| private LineOutput InstantiateLineOutputInterface() | |
| { | |
| PrinterLineOutput printOutput = new(_printerName); | |
| return (LineOutput)printOutput; | |
| } | |
| } | |
| } | |