/// <summary>
        /// Compares two instances of this object.
        /// </summary>
        /// <param name="QRCodeIdentification">An QR code identification with (hashed) pin object to compare with.</param>
        public Int32 CompareTo(QRCodeIdentification QRCodeIdentification)
        {
            if ((Object)QRCodeIdentification == null)
            {
                throw new ArgumentNullException(nameof(QRCodeIdentification), "The given QR code identification with (hashed) pin must not be null!");
            }

            var result = EVCOId.CompareTo(QRCodeIdentification.EVCOId);

            if (result == 0)
            {
                result = String.Compare(PIN, QRCodeIdentification.PIN, StringComparison.OrdinalIgnoreCase);
            }

            if (result == 0)
            {
                result = Function.CompareTo(QRCodeIdentification.Function);
            }

            if (result == 0)
            {
                result = String.Compare(Salt, QRCodeIdentification.Salt, StringComparison.OrdinalIgnoreCase);
            }

            return(result);
        }
        /// <summary>
        /// Return a JSON representation of this object.
        /// </summary>
        /// <param name="CustomQRCodeIdentificationSerializer">A delegate to serialize custom QR code identification JSON objects.</param>
        public JObject ToJSON(CustomJObjectSerializerDelegate <QRCodeIdentification> CustomQRCodeIdentificationSerializer = null)
        {
            var JSON = JSONObject.Create(

                new JProperty("EvcoID", EVCOId.ToString()),

                PIN.IsNotNullOrEmpty()

                               ? Function == PINCrypto.None

                                     ? new JProperty("PIN", PIN)

                                     : new JProperty("HashedPIN", JSONObject.Create(
                                                         new JProperty("Value", PIN),
                                                         new JProperty("Function", Function.AsString()),
                                                         new JProperty("Salt", Salt)
                                                         ))

                               : null

                );

            return(CustomQRCodeIdentificationSerializer != null
                       ? CustomQRCodeIdentificationSerializer(this, JSON)
                       : JSON);
        }
        /// <summary>
        /// Return a text-representation of this object.
        /// </summary>
        public override String ToString()

        => String.Concat(EVCOId.ToString(),
                         Function != PINCrypto.None
                                 ? String.Concat(" -", Function.AsString(), "-> ",
                                                 PIN,
                                                 Salt.IsNotNullOrEmpty() ? " (" + Salt + ")" : "")
                                 : PIN);
 /// <summary>
 /// Get the hashcode of this object.
 /// </summary>
 public override Int32 GetHashCode()
 {
     unchecked
     {
         return(EVCOId.GetHashCode() * 7 ^
                PIN.GetHashCode() * 5 ^
                Function.GetHashCode() * 3 ^
                Salt.GetHashCode());
     }
 }
        /// <summary>
        /// Compares two QR code identifications with (hashed) pins for equality.
        /// </summary>
        /// <param name="QRCodeIdentification">An QR code identification with (hashed) pin to compare with.</param>
        /// <returns>True if both match; False otherwise.</returns>
        public Boolean Equals(QRCodeIdentification QRCodeIdentification)
        {
            if ((Object)QRCodeIdentification == null)
            {
                return(false);
            }

            return(EVCOId.Equals(QRCodeIdentification.EVCOId) &&
                   PIN.Equals(QRCodeIdentification.PIN) &&
                   Function.Equals(QRCodeIdentification.Function) &&
                   Salt.Equals(QRCodeIdentification.Salt));
        }
        /// <summary>
        /// Return a XML representation of this object.
        /// </summary>
        /// <param name="XName">The XML name to use.</param>
        public XElement ToXML(XName XName = null)

        => new XElement(XName ?? OICPNS.CommonTypes + "QRCodeIdentification",

                        new XElement(OICPNS.CommonTypes + "EvcoID", EVCOId.ToString()),

                        Function == PINCrypto.None

                       ? new XElement(OICPNS.CommonTypes + "PIN", PIN)

                       : new XElement(OICPNS.CommonTypes + "HashedPIN",
                                      new XElement(OICPNS.CommonTypes + "Value", PIN),
                                      new XElement(OICPNS.CommonTypes + "Function", Function.AsString()),
                                      new XElement(OICPNS.CommonTypes + "Salt", Salt))

                        );
        /// <summary>
        /// Get the hashcode of this object.
        /// </summary>
        public override Int32 GetHashCode()
        {
            unchecked
            {
                return(EVCOId.GetHashCode() * 11 ^
                       RFIDType.GetHashCode() * 7 ^

                       (EVCOId.HasValue
                            ? EVCOId.GetHashCode() * 5
                            : 0) ^

                       (PrintedNumber != null
                            ? PrintedNumber.GetHashCode() * 3
                            : 0) ^

                       (EVCOId.HasValue
                            ? EVCOId.GetHashCode()
                            : 0));
            }
        }
        /// <summary>
        /// Return a JSON representation of this object.
        /// </summary>
        /// <param name="CustomQRCodeIdentificationSerializer">A delegate to serialize custom QR code identification JSON objects.</param>
        /// <param name="CustomHashedPINSerializer">A delegate to serialize custom QR code identification JSON objects.</param>
        public JObject ToJSON(CustomJObjectSerializerDelegate <QRCodeIdentification> CustomQRCodeIdentificationSerializer = null,
                              CustomJObjectSerializerDelegate <HashedPIN> CustomHashedPINSerializer = null)
        {
            var JSON = JSONObject.Create(

                new JProperty("EvcoID", EVCOId.ToString()),

                HashedPIN.HasValue
                               ? new JProperty("HashedPIN", HashedPIN.Value.ToJSON(CustomHashedPINSerializer))
                               : null,

                PIN.HasValue
                               ? new JProperty("PIN", PIN.Value.ToString())
                               : null

                );

            return(CustomQRCodeIdentificationSerializer != null
                       ? CustomQRCodeIdentificationSerializer(this, JSON)
                       : JSON);
        }
        /// <summary>
        /// Return a XML representation of this object.
        /// </summary>
        /// <param name="XName">The XML name to use.</param>
        public XElement ToXML(XName XName = null)

        => new XElement(XName ?? OICPNS.CommonTypes + "RFIDIdentification",

                        new XElement(OICPNS.CommonTypes + "UID", UID.ToString()),

                        EVCOId.HasValue
                       ? new XElement(OICPNS.CommonTypes + "EvcoID", EVCOId.ToString())
                       : null,

                        new XElement(OICPNS.CommonTypes + "RFIDType", RFIDType.ToString()),

                        PrintedNumber.IsNeitherNullNorEmpty()
                       ? new XElement(OICPNS.CommonTypes + "PrintedNumber", PrintedNumber)
                       : null,

                        ExpiryDate.HasValue
                       ? new XElement(OICPNS.CommonTypes + "ExpiryDate", ExpiryDate.ToString())
                       : null

                        );
        /// <summary>
        /// Return a JSON representation of this object.
        /// </summary>
        /// <param name="CustomRFIDIdentificationSerializer">A delegate to serialize custom RFID identification JSON objects.</param>
        public JObject ToJSON(CustomJObjectSerializerDelegate <RFIDIdentification> CustomRFIDIdentificationSerializer = null)
        {
            var JSON = JSONObject.Create(

                new JProperty("UID", UID.ToString()),

                EVCOId.HasValue
                               ? new JProperty("EvcoID", EVCOId.ToString())
                               : null,

                new JProperty("RFIDType", RFIDType.ToString()),

                PrintedNumber.IsNeitherNullNorEmpty()
                               ? new JProperty("PrintedNumber", PrintedNumber)
                               : null,

                ExpiryDate.HasValue
                               ? new JProperty("ExpiryDate", ExpiryDate.ToString())
                               : null);

            return(CustomRFIDIdentificationSerializer != null
                       ? CustomRFIDIdentificationSerializer(this, JSON)
                       : JSON);
        }