Пример #1
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

            );
Пример #2
0
        /// <summary>
        /// Return a XML representation of this object.
        /// </summary>
        /// <param name="XName">The XML name to use.</param>
        /// <param name="CustomIdentificationSerializer">A delegate to serialize custom Identification XML elements.</param>
        public XElement ToXML(XName XName = null,
                              CustomXMLSerializerDelegate <Identification> CustomIdentificationSerializer = null)

        {
            var XML = new XElement(XName ?? OICPNS.Authorization + "Identification",

                                   RFIDId.HasValue
                              ? new XElement(OICPNS.CommonTypes + "RFIDMifareFamilyIdentification",
                                             new XElement(OICPNS.CommonTypes + "UID", RFIDId.ToString()))
                              : null,

                                   RFIDIdentification.HasValue
                              ? RFIDIdentification.Value.ToXML()
                              : null,

                                   QRCodeIdentification.HasValue
                              ? QRCodeIdentification.Value.ToXML()
                              : null,

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

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

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