Example #1
0
        /// <summary>
        /// Compares two instances of this object.
        /// </summary>
        /// <param name="AAuthentication">An object to compare with.</param>
        public Int32 CompareTo(AAuthentication AAuthentication)
        {
            if ((Object)AAuthentication == null)
            {
                throw new ArgumentNullException(nameof(AAuthentication), "The given abstract authentication must not be null!");
            }

            if (AuthToken.HasValue && AAuthentication.AuthToken.HasValue)
            {
                return(AuthToken.Value.CompareTo(AAuthentication.AuthToken.Value));
            }

            if (QRCodeIdentification != null && AAuthentication.QRCodeIdentification != null)
            {
                return(QRCodeIdentification.CompareTo(AAuthentication.QRCodeIdentification));
            }

            if (PlugAndChargeIdentification.HasValue && AAuthentication.PlugAndChargeIdentification.HasValue)
            {
                return(PlugAndChargeIdentification.Value.CompareTo(AAuthentication.PlugAndChargeIdentification.Value));
            }

            if (RemoteIdentification.HasValue && AAuthentication.RemoteIdentification.HasValue)
            {
                return(RemoteIdentification.Value.CompareTo(AAuthentication.RemoteIdentification.Value));
            }

            if (PIN.HasValue && AAuthentication.PIN.HasValue)
            {
                return(PIN.Value.CompareTo(AAuthentication.PIN.Value));
            }

            if (PublicKey != null && AAuthentication.PublicKey != null)
            {
                return(PublicKey.Fingerprint.ToHexString().CompareTo(AAuthentication.PublicKey.Fingerprint.ToHexString()));
            }

            return(String.Compare(ToString(), AAuthentication.ToString(), StringComparison.OrdinalIgnoreCase));
        }