示例#1
0
        /// <summary>
        /// Return a text-representation of this object.
        /// </summary>
        public override String ToString()

        => String.Concat(Country.CountryName.FirstText(), ", ",
                         City, ", ",
                         Street,

                         PostalCode.IsNotNullOrEmpty()
                                 ? ", " + PostalCode
                                 : "",

                         HouseNumber.IsNotNullOrEmpty()
                                 ? ", " + HouseNumber
                                 : "",

                         FloorLevel.IsNotNullOrEmpty()
                                 ? ", " + FloorLevel
                                 : "",

                         Region.IsNotNullOrEmpty()
                                 ? ", " + Region
                                 : "",

                         Timezone.IsNotNullOrEmpty()
                                 ? ", " + Timezone
                                 : "");
示例#2
0
        /// <summary>
        /// Return a XML representation of this EVSE data record.
        /// </summary>
        /// <param name="XName">The XML name to use.</param>
        /// <param name="CustomAddressSerializer">A delegate to serialize custom Address XML elements.</param>
        public XElement ToXML(XName XName = null,
                              CustomXMLSerializerDelegate <Address> CustomAddressSerializer = null)
        {
            var XML = new XElement(XName ?? OICPNS.EVSEData + "Address",

                                   new XElement(OICPNS.CommonTypes + "Country", Country.Alpha3Code),
                                   new XElement(OICPNS.CommonTypes + "City", City.FirstText()),
                                   new XElement(OICPNS.CommonTypes + "Street", Street),

                                   PostalCode.IsNotNullOrEmpty()
                              ? new XElement(OICPNS.CommonTypes + "PostalCode", PostalCode)
                              : null,

                                   HouseNumber.IsNotNullOrEmpty()
                              ? new XElement(OICPNS.CommonTypes + "HouseNum", HouseNumber)
                              : null,

                                   FloorLevel.IsNotNullOrEmpty()
                              ? new XElement(OICPNS.CommonTypes + "Floor", FloorLevel)
                              : null,

                                   Region.IsNotNullOrEmpty()
                              ? new XElement(OICPNS.CommonTypes + "Region", Region)
                              : null,

                                   Timezone.IsNotNullOrEmpty()
                              ? new XElement(OICPNS.CommonTypes + "TimeZone", Timezone)
                              : null

                                   );

            return(CustomAddressSerializer != null
                       ? CustomAddressSerializer(this, XML)
                       : XML);
        }
示例#3
0
        /// <summary>
        /// Return the HashCode of this object.
        /// </summary>
        /// <returns>The HashCode of this object.</returns>
        public override Int32 GetHashCode()
        {
            unchecked
            {
                return(Country.GetHashCode() * 19 ^
                       City.GetHashCode() * 17 ^
                       Street.GetHashCode() * 13 ^

                       (PostalCode.IsNotNullOrEmpty()
                            ? PostalCode.GetHashCode() * 11
                            : 0) ^

                       (HouseNumber.IsNotNullOrEmpty()
                            ? HouseNumber.GetHashCode() * 7
                            : 0) ^

                       (FloorLevel.IsNotNullOrEmpty()
                            ? FloorLevel.GetHashCode() * 5
                            : 0) ^

                       (Region.IsNotNullOrEmpty()
                            ? Region.GetHashCode() * 3
                            : 0) ^

                       (Timezone.IsNotNullOrEmpty()
                            ? Timezone.GetHashCode()
                            : 0));
            }
        }
        /// <summary>
        /// Return a JSON representation of this object.
        /// </summary>
        /// <param name="CustomCDRLocationSerializer">A delegate to serialize custom location JSON objects.</param>
        public JObject ToJSON(CustomJObjectSerializerDelegate <CDRLocation> CustomCDRLocationSerializer = null)
        {
            var JSON = JSONObject.Create(

                new JProperty("id", Id.ToString()),

                Name.IsNotNullOrEmpty()
                               ? new JProperty("name", Name)
                               : null,

                new JProperty("address", Address),
                new JProperty("city", City),

                PostalCode.IsNotNullOrEmpty()
                               ? new JProperty("postal_code", PostalCode)
                               : null,

                new JProperty("country", Country),

                new JProperty("coordinates", new JObject(
                                  new JProperty("latitude", Coordinates.Latitude.Value.ToString("0.00000##").Replace(",", ".")),
                                  new JProperty("longitude", Coordinates.Longitude.Value.ToString("0.00000##").Replace(",", "."))
                                  )),

                new JProperty("evse_uid", EVSEUId.ToString()),
                new JProperty("evse_id", EVSEId.ToString()),
                new JProperty("connector_id", ConnectorId.ToString()),
                new JProperty("connector_standard", ConnectorStandard.ToString()),
                new JProperty("connector_format", ConnectorFormat.ToString()),
                new JProperty("connector_power_type", ConnectorPowerType.ToString())

                );

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