Example #1
0
        /// <summary>
        /// Return a text representation of this object.
        /// </summary>
        public override String ToString()
        {
            if (AuthToken.HasValue)
            {
                return(AuthToken.ToString());
            }

            if (QRCodeIdentification != null)
            {
                return(QRCodeIdentification.ToString());
            }

            if (PlugAndChargeIdentification.HasValue)
            {
                return(PlugAndChargeIdentification.Value.ToString());
            }

            if (RemoteIdentification.HasValue)
            {
                return(RemoteIdentification.Value.ToString());
            }

            if (PIN.HasValue)
            {
                return(PIN.Value.ToString());
            }

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

            return(String.Empty);
        }
Example #2
0
        public JObject ToJSON()

        => JSONObject.Create(

            AuthToken.HasValue
                       ? new JProperty("authToken", AuthToken.ToString())
                       : null,

            QRCodeIdentification != null
                       ? new JProperty("QRCodeIdentification", QRCodeIdentification.ToString())
                       : null,

            PlugAndChargeIdentification.HasValue
                       ? new JProperty("plugAndChargeIdentification", PlugAndChargeIdentification.ToString())
                       : null,

            RemoteIdentification.HasValue
                       ? new JProperty("remoteIdentification", RemoteIdentification.ToString())
                       : null,

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

            PublicKey != null
                       ? new JProperty("publicKey", PublicKey.ToString())
                       : null

            );
Example #3
0
        /// <summary>
        /// Return the HashCode of this object.
        /// </summary>
        /// <returns>The HashCode of this object.</returns>
        public override Int32 GetHashCode()
        {
            unchecked
            {
                return(EVSEId.GetHashCode() * 7 ^
                       QRCodeIdentification.GetHashCode() * 5 ^

                       (PartnerProductId.HasValue
                            ? PartnerProductId.GetHashCode() * 3
                            : 0) ^

                       (!GetNewSession.HasValue
                            ? GetNewSession.GetHashCode()
                            : 0));
            }
        }
Example #4
0
        /// <summary>
        /// Compares two mobile authorize start requests for equality.
        /// </summary>
        /// <param name="MobileAuthorizeStartRequest">A mobile authorize start request to compare with.</param>
        /// <returns>True if both match; False otherwise.</returns>
        public override Boolean Equals(MobileAuthorizeStartRequest MobileAuthorizeStartRequest)
        {
            if ((Object)MobileAuthorizeStartRequest == null)
            {
                return(false);
            }

            return(EVSEId.Equals(MobileAuthorizeStartRequest.EVSEId) &&
                   QRCodeIdentification.Equals(MobileAuthorizeStartRequest.QRCodeIdentification) &&

                   ((!PartnerProductId.HasValue && !MobileAuthorizeStartRequest.PartnerProductId.HasValue) ||
                    (PartnerProductId.HasValue && MobileAuthorizeStartRequest.PartnerProductId.HasValue && PartnerProductId.Value.Equals(MobileAuthorizeStartRequest.PartnerProductId.Value))) &&

                   ((!GetNewSession.HasValue && !MobileAuthorizeStartRequest.GetNewSession.HasValue) ||
                    (GetNewSession.HasValue && MobileAuthorizeStartRequest.GetNewSession.HasValue && GetNewSession.Value.Equals(MobileAuthorizeStartRequest.GetNewSession.Value))));
        }
        MobileAuthorizeStart(this IMobileClient IMobileClient,
                             EVSE_Id EVSEId,
                             QRCodeIdentification QRCodeIdentification,
                             PartnerProduct_Id?PartnerProductId = null,
                             Boolean?GetNewSession = null,

                             DateTime?Timestamp = null,
                             CancellationToken?CancellationToken = null,
                             EventTracking_Id EventTrackingId    = null,
                             TimeSpan?RequestTimeout             = null)


        => IMobileClient.MobileAuthorizeStart(new MobileAuthorizeStartRequest(EVSEId,
                                                                              QRCodeIdentification,
                                                                              PartnerProductId,
                                                                              GetNewSession,

                                                                              Timestamp,
                                                                              CancellationToken,
                                                                              EventTrackingId,
                                                                              RequestTimeout ?? IMobileClient.RequestTimeout));
Example #6
0
        /// <summary>
        /// Create a new MobileAuthorizeStart request.
        /// </summary>
        /// <param name="EVSEId">The EVSE identification.</param>
        /// <param name="EVCOIdWithPIN">The EVCO identification with its PIN.</param>
        /// <param name="ProductId">An optional charging product identification.</param>
        /// <param name="GetNewSession">Whether to start a new charging session or not.</param>
        ///
        /// <param name="Timestamp">The optional timestamp of the request.</param>
        /// <param name="CancellationToken">An optional token to cancel this request.</param>
        /// <param name="EventTrackingId">An optional event tracking identification for correlating this request with other events.</param>
        /// <param name="RequestTimeout">An optional timeout for this request.</param>
        public MobileAuthorizeStartRequest(EVSE_Id EVSEId,
                                           QRCodeIdentification QRCodeIdentification,
                                           PartnerProduct_Id?PartnerProductId = null,
                                           Boolean?GetNewSession = null,

                                           DateTime?Timestamp = null,
                                           CancellationToken?CancellationToken = null,
                                           EventTracking_Id EventTrackingId    = null,
                                           TimeSpan?RequestTimeout             = null)

            : base(Timestamp,
                   CancellationToken,
                   EventTrackingId,
                   RequestTimeout)

        {
            this.EVSEId = EVSEId;
            this.QRCodeIdentification = QRCodeIdentification;
            this.PartnerProductId     = PartnerProductId;
            this.GetNewSession        = GetNewSession;
        }
Example #7
0
        /// <summary>
        /// Compares two EVSE identifications for equality.
        /// </summary>
        /// <param name="AAuthentication">An EVSE identification to compare with.</param>
        /// <returns>True if both match; False otherwise.</returns>
        public Boolean Equals(AAuthentication AAuthentication)
        {
            if ((Object)AAuthentication == null)
            {
                return(false);
            }

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

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

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

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

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

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

            return(false);
        }
Example #8
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));
        }
Example #9
0
        /// <summary>
        /// Return a XML representation of this object.
        /// </summary>
        /// <param name="CustomMobileAuthorizeStartRequestSerializer">A delegate to serialize custom MobileAuthorizeStart XML elements.</param>
        public XElement ToXML(CustomXMLSerializerDelegate <MobileAuthorizeStartRequest> CustomMobileAuthorizeStartRequestSerializer = null)
        {
            var XML = new XElement(OICPNS.MobileAuthorization + "eRoamingMobileAuthorizeStart",

                                   new XElement(OICPNS.MobileAuthorization + "EvseID", EVSEId.ToString()),

                                   QRCodeIdentification.ToXML(OICPNS.MobileAuthorization + "QRCodeIdentification"),

                                   PartnerProductId.HasValue
                                          ? new XElement(OICPNS.MobileAuthorization + "PartnerProductID", PartnerProductId.ToString())
                                          : null,

                                   (GetNewSession.HasValue)
                                          ? new XElement(OICPNS.MobileAuthorization + "GetNewSession", GetNewSession.Value ? "true" : "false")
                                          : null

                                   );

            return(CustomMobileAuthorizeStartRequestSerializer != null
                       ? CustomMobileAuthorizeStartRequestSerializer(this, XML)
                       : XML);
        }