File size: 1,935 Bytes
8c763fb | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | // 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>
[Cmdlet(VerbsData.Out, "Printer", HelpUri = "https://go.microsoft.com/fwlink/?LinkID=2109553")]
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>
[Parameter(Position = 0)]
[Alias("PrinterName")]
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;
}
}
}
|