Esempio n. 1
0
        /// <summary>
        /// Return a JSON representation of this object.
        /// </summary>
        /// <param name="CustomStatusNotificationRequestSerializer">A delegate to serialize custom StatusNotification requests.</param>
        public JObject ToJSON(CustomJObjectSerializerDelegate <StatusNotificationRequest> CustomStatusNotificationRequestSerializer)
        {
            var JSON = JSONObject.Create(

                new JProperty("connectorId", ConnectorId.Value),
                new JProperty("status", Status.AsText()),
                new JProperty("errorCode", ErrorCode.AsText()),

                Info.IsNotNullOrEmpty()
                               ? new JProperty("info", Info)
                               : null,

                StatusTimestamp.HasValue
                               ? new JProperty("timestamp", StatusTimestamp.Value.ToIso8601())
                               : null,

                VendorId.IsNotNullOrEmpty()
                               ? new JProperty("vendorId", VendorId)
                               : null,

                VendorErrorCode.IsNotNullOrEmpty()
                               ? new JProperty("vendorErrorCode", VendorErrorCode)
                               : null);

            return(CustomStatusNotificationRequestSerializer != null
                       ? CustomStatusNotificationRequestSerializer(this, JSON)
                       : JSON);
        }
Esempio n. 2
0
        /// <summary>
        /// Return a XML representation of this object.
        /// </summary>
        public XElement ToXML()

        => new XElement(OCPPNS.OCPPv1_6_CS + "statusNotificationRequest",

                        new XElement(OCPPNS.OCPPv1_6_CS + "connectorId", ConnectorId.ToString()),
                        new XElement(OCPPNS.OCPPv1_6_CS + "status", Status.AsText()),
                        new XElement(OCPPNS.OCPPv1_6_CS + "errorCode", ErrorCode.AsText()),

                        Info.IsNotNullOrEmpty()
                       ? new XElement(OCPPNS.OCPPv1_6_CS + "info", Info)
                       : null,

                        StatusTimestamp.HasValue
                       ? new XElement(OCPPNS.OCPPv1_6_CS + "timestamp", StatusTimestamp.Value.ToIso8601())
                       : null,

                        VendorId.IsNotNullOrEmpty()
                       ? new XElement(OCPPNS.OCPPv1_6_CS + "vendorId", VendorId)
                       : null,

                        VendorErrorCode.IsNotNullOrEmpty()
                       ? new XElement(OCPPNS.OCPPv1_6_CS + "vendorErrorCode", VendorErrorCode)
                       : null

                        );