/// <summary> /// Initializes a new instance of the <see cref="DynamicLocalPrintQueueDefinition" /> class. /// </summary> /// <param name="printQueueInfo">The <see cref="DynamicLocalPrintQueueInfo" /> whose information should be stored.</param> /// <exception cref="ArgumentNullException"><paramref name="printQueueInfo" /> is null.</exception> public DynamicLocalPrintQueueDefinition(DynamicLocalPrintQueueInfo printQueueInfo) { if (printQueueInfo == null) { throw new ArgumentNullException(nameof(printQueueInfo)); } _assetId = printQueueInfo.AssociatedAssetId; _printDriverId = printQueueInfo.PrintDriver.PrintDriverId; _printerPort = printQueueInfo.PrinterPort; _printDriverConfiguration = printQueueInfo.PrintDriverConfiguration; }
/// <summary> /// Initializes a new instance of the <see cref="DynamicLocalPrintQueueInfo" /> class. /// </summary> /// <param name="assetId">The asset identifier for the asset associated with this print queue.</param> /// <param name="address">The network address to use for this print queue.</param> /// <param name="printDriver">The print driver to use for this print queue.</param> /// <param name="printerPort">The <see cref="PrinterPortInfo" /> to use when creating the queue.</param> /// <param name="portNumber">The port number to use when creating the queue.</param> /// <param name="snmpEnabled">Indicates whether SNMP should be enabled when creating the queue.</param> /// <param name="printDriverConfiguration">The print driver configuration.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="address" /> is null. /// <para>or</para> /// <paramref name="printDriver" /> is null. /// <para>or</para> /// <paramref name="printerPort" /> is null. /// </exception> /// <exception cref="ArgumentException"><paramref name="address" /> is an empty string.</exception> public DynamicLocalPrintQueueInfo(string assetId, string address, PrintDriverInfo printDriver, PrinterPortInfo printerPort, int portNumber, bool snmpEnabled, PrintDriverConfiguration printDriverConfiguration) : base(BuildQueueName(address, portNumber, printDriver, printDriverConfiguration), assetId) { if (address == null) { throw new ArgumentNullException(nameof(address)); } if (string.IsNullOrEmpty(address)) { throw new ArgumentException("Address cannot be an empty string.", nameof(address)); } _address = address; _printDriver = printDriver ?? throw new ArgumentNullException(nameof(printDriver)); _printerPort = printerPort ?? throw new ArgumentNullException(nameof(printerPort)); _portNumber = portNumber; _snmpEnabled = snmpEnabled; _printDriverConfiguration = printDriverConfiguration ?? new PrintDriverConfiguration(); }
/// <summary> /// Initializes a new instance of the <see cref="DynamicLocalPrintQueueDefinition" /> class. /// </summary> /// <param name="assetId">The asset identifier.</param> /// <param name="printDriverId">The print driver identifier.</param> /// <param name="printerPort">The <see cref="PrinterPortInfo" /> information.</param> /// <param name="printDriverConfiguration">The print driver configuration.</param> public DynamicLocalPrintQueueDefinition(string assetId, Guid printDriverId, PrinterPortInfo printerPort, PrintDriverConfiguration printDriverConfiguration) : this(assetId, printDriverId, printerPort) { _printDriverConfiguration = printDriverConfiguration; }
private static string BuildQueueName(string address, int portNumber, PrintDriverInfo printDriver, PrintDriverConfiguration configuration = null) { if (configuration == null) { return($"{printDriver?.DriverName} (IP_{address}:{portNumber})"); } else { return($"{printDriver?.DriverName} ({configuration.FileName}_IP_{address}:{portNumber})"); } }
/// <summary> /// Initializes a new instance of the <see cref="DynamicLocalPrintQueueInfo" /> class. /// </summary> /// <param name="printDevice">The print device to use for this print queue.</param> /// <param name="printDriver">The print driver to use for this print queue.</param> /// <param name="printerPort">The <see cref="PrinterPortInfo" /> to use when creating the queue.</param> /// <param name="printDriverConfiguration">The print driver configuration.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="printDevice" /> is null. /// <para>or</para> /// <paramref name="printDriver" /> is null. /// <para>or</para> /// <paramref name="printerPort" /> is null. /// </exception> public DynamicLocalPrintQueueInfo(IPrinterInfo printDevice, PrintDriverInfo printDriver, PrinterPortInfo printerPort, PrintDriverConfiguration printDriverConfiguration) : this(printDevice?.AssetId, printDevice?.Address, printDriver, printerPort, printDevice?.PrinterPort ?? 0, printDevice?.SnmpEnabled ?? false, printDriverConfiguration) { }