Ejemplo n.º 1
0
 /// <summary>
 /// Return the HashCode of this object.
 /// </summary>
 /// <returns>The HashCode of this object.</returns>
 public override Int32 GetHashCode()
 {
     unchecked
     {
         return(Street.GetHashCode() * 17 ^
                HouseNumber.GetHashCode() * 13 ^
                FloorLevel.GetHashCode() * 11 ^
                PostalCode.GetHashCode() * 7 ^
                PostalCodeSub.GetHashCode() * 5 ^
                City.GetHashCode() * 3 ^
                Country.GetHashCode());
     }
 }
Ejemplo n.º 2
0
        //public static Address Parse(String Text)
        //{

        //    if (TryParseJSON(JObject.Parse(Text), out Address _Address))
        //        return _Address;

        //    return null;

        //}

        //public static Address ParseAddressJSON(JObject JSONObject, String PropertyKey)
        //{

        //    try
        //    {

        //        if (JSONObject[PropertyKey] is JObject JSON)
        //            return Create(Country.Parse(JSON["country"    ]?.Value<String>()),
        //                                        JSON["postalCode" ]?.Value<String>(),
        //                                       (JSON["city"       ] as JObject)?.ParseI18NString(),
        //                                        JSON["street"     ]?.Value<String>(),
        //                                        JSON["houseNumber"]?.Value<String>(),
        //                                        JSON["floorLevel" ]?.Value<String>(),
        //                                       (JSON["comment"    ] as JObject)?.ParseI18NString());

        //    }
        //    catch (Exception)
        //    { }

        //    return null;

        //}


        #region ToJSON(...)

        /// <summary>
        /// Return a JSON representation of this object.
        /// </summary>
        /// <param name="Embedded">Whether this data is embedded into another data structure.</param>
        public JObject ToJSON(Boolean Embedded = false)

        => JSONObject.Create(

            !Embedded
                       ? new JProperty("@context", JSONLDContext.ToString())
                       : null,

            FloorLevel.ToJSON("floorLevel"),
            HouseNumber.ToJSON("houseNumber"),
            Street.ToJSON("street"),
            PostalCode.ToJSON("postalCode"),
            PostalCodeSub.ToJSON("postalCodeSub"),
            City.ToJSON("city"),
            Country?.Alpha3Code.ToJSON("country"),
            Comment.ToJSON("comment")

            );
Ejemplo n.º 3
0
        /// <summary>
        /// Compares two addresses for equality.
        /// </summary>
        /// <param name="Address">An address to compare with.</param>
        /// <returns>True if both match; False otherwise.</returns>
        public Boolean Equals(Address Address)
        {
            if ((Object)Address == null)
            {
                return(false);
            }

            try
            {
                return(Street.Equals(Address.Street) &&
                       HouseNumber.Equals(Address.HouseNumber) &&
                       FloorLevel.Equals(Address.FloorLevel) &&
                       PostalCode.Equals(Address.PostalCode) &&
                       PostalCodeSub.Equals(Address.PostalCodeSub) &&
                       City.Equals(Address.City) &&
                       Country.Equals(Address.Country));
            }
            catch (Exception e)
            {
                return(false);
            }
        }