Exemplo n.º 1
0
        /// <summary>
        /// Encodes the QR bill data as a text to be embedded in a QR code.
        /// <para>
        /// The specified bill data is first validated and cleaned.
        /// </para>
        /// <para>
        /// If the bill data is invalid, a <see cref="QRBillValidationException"/> is
        /// thrown, containing the validation result. For details about the
        /// validation result, see
        /// <a href="https://github.com/manuelbl/SwissBillQR/wiki/Bill-data-validation">Bill data
        /// validation</a>
        /// </para>
        /// </summary>
        /// <param name="bill">The bill data to encode.</param>
        /// <returns>The text to embed in a QR code.</returns>
        /// <exception cref="QRBillValidationException">The bill data is invalid.</exception>
        public static string EncodeQrCodeText(Bill bill)
        {
            ValidationResult result      = Validator.Validate(bill);
            Bill             cleanedBill = result.CleanedBill;

            if (result.HasErrors)
            {
                throw new QRBillValidationException(result);
            }

            return(QRCodeText.Create(cleanedBill));
        }
Exemplo n.º 2
0
 /// <summary>
 /// Creates an instance of the QR code for the specified bill data.
 /// <para>
 /// The bill data must have been validated and cleaned.
 /// </para>
 /// </summary>
 /// <param name="bill">The bill data.</param>
 internal QRCode(Bill bill)
 {
     _embeddedText = QRCodeText.Create(bill);
 }