Exemplo n.º 1
0
        /// <summary>
        /// Return a JSON representation of this object.
        /// </summary>
        /// <param name="CustomChargingFacilitySerializer">A delegate to serialize custom charging facility JSON objects.</param>
        public JObject ToJSON(CustomJObjectSerializerDelegate <ChargingFacility> CustomChargingFacilitySerializer = null)
        {
            var JSON = JSONObject.Create(

                new JProperty("PowerType", PowerType.AsString()),
                new JProperty("Power", Power),

                Voltage.HasValue
                               ? new JProperty("Voltage", Voltage.Value)
                               : null,

                Amperage.HasValue
                               ? new JProperty("Amperage", Amperage.Value)
                               : null,

                ChargingModes.SafeAny()
                               ? new JProperty("ChargingModes", new JArray(ChargingModes.Select(chargingMode => chargingMode.AsString())))
                               : null,

                CustomData?.HasValues == true
                               ? new JProperty("CustomData", CustomData)
                               : null

                );

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