コード例 #1
0
ファイル: ChargingProfile.cs プロジェクト: xrjob/WWCP_OCPP
        /// <summary>
        /// Return a XML representation of this object.
        /// </summary>
        /// <param name="XName">An alternative XML element name [default: "OCPPv1_6_CP:chargingProfile"]</param>
        public XElement ToXML(XName XName = null)

        => new XElement(XName ?? OCPPNS.OCPPv1_6_CP + "chargingProfile",

                        new XElement(OCPPNS.OCPPv1_6_CP + "chargingProfileId", ChargingProfileId.ToString()),

                        TransactionId != null
                       ? new XElement(OCPPNS.OCPPv1_6_CP + "transactionId", TransactionId.ToString())
                       : null,

                        new XElement(OCPPNS.OCPPv1_6_CP + "stackLevel", StackLevel),
                        new XElement(OCPPNS.OCPPv1_6_CP + "chargingProfilePurpose", ChargingProfilePurpose.AsText()),
                        new XElement(OCPPNS.OCPPv1_6_CP + "chargingProfileKind", ChargingProfileKind.AsText()),

                        ValidFrom.HasValue
                       ? new XElement(OCPPNS.OCPPv1_6_CP + "validFrom", ValidFrom.Value.ToIso8601())
                       : null,

                        ValidTo.HasValue
                       ? new XElement(OCPPNS.OCPPv1_6_CP + "validTo", ValidTo.Value.ToIso8601())
                       : null,

                        RecurrencyKind.HasValue
                       ? new XElement(OCPPNS.OCPPv1_6_CP + "recurrencyKind", RecurrencyKind.Value.AsText())
                       : null,

                        ChargingSchedule.ToXML()

                        );
コード例 #2
0
ファイル: ChargingProfile.cs プロジェクト: xrjob/WWCP_OCPP
        /// <summary>
        /// Return a JSON representation of this object.
        /// </summary>
        /// <param name="CustomChargingProfileSerializer">A delegate to serialize custom charging profiles.</param>
        /// <param name="CustomChargingScheduleSerializer">A delegate to serialize custom charging schedule requests.</param>
        /// <param name="CustomChargingSchedulePeriodSerializer">A delegate to serialize custom charging schedule periods.</param>
        public JObject ToJSON(CustomJObjectSerializerDelegate <ChargingProfile> CustomChargingProfileSerializer               = null,
                              CustomJObjectSerializerDelegate <ChargingSchedule> CustomChargingScheduleSerializer             = null,
                              CustomJObjectSerializerDelegate <ChargingSchedulePeriod> CustomChargingSchedulePeriodSerializer = null)
        {
            var JSON = JSONObject.Create(

                new JProperty("chargingProfileId", ChargingProfileId.ToString()),

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

                new JProperty("stackLevel", StackLevel),
                new JProperty("chargingProfilePurpose", ChargingProfilePurpose.AsText()),
                new JProperty("chargingProfileKind", ChargingProfileKind.AsText()),

                ValidFrom.HasValue
                               ? new JProperty("validFrom", ValidFrom.Value.ToIso8601())
                               : null,

                ValidTo.HasValue
                               ? new JProperty("validTo", ValidTo.Value.ToIso8601())
                               : null,

                RecurrencyKind.HasValue
                               ? new JProperty("recurrencyKind", RecurrencyKind.Value.AsText())
                               : null,

                new JProperty("chargingSchedule", ChargingSchedule.ToJSON(CustomChargingScheduleSerializer,
                                                                          CustomChargingSchedulePeriodSerializer))

                );

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