public string GenerateMergeKey()
        {
            var mergeKey = $"{StateTerritory}|{LocalityName}|{Postcode}|";

            if (PostalDeliveryType.HasValue())
            {
                if (PostalDeliveryNumber.HasValue())
                {
                    mergeKey += $"|||{PostalDeliveryType} {PostalDeliveryNumber}||||||";
                }
                else
                {
                    mergeKey += $"|||{PostalDeliveryType}||||||";
                }
            }
            else
            {
                if (StreetNumber1.HasValue())
                {
                    mergeKey += $"{StreetName}|{StreetType}|{StreetSuffix}|{StreetNumber1}|";
                }
                else
                {
                    mergeKey += $"{StreetName}|{StreetType}|{StreetSuffix}|LOT {LotIdentifier}|";
                }
                mergeKey += $"{StreetNumber2}|{SiteName}|{ComplexUnitType}|{ComplexUnitIdentifier}|{ComplexLevelType}|{ComplexLevelNumber}";
            }
            return(mergeKey);
        }
        public string GenerateDisplayAddress()
        {
            // full_address_string = (postal_address / street_address) locality_part
            var displayAddressBuilder = new StringBuilder();

            if (PostalDeliveryType.HasValue())
            {
                BuildPostalAddressPart(displayAddressBuilder);
            }
            else
            {
                BuildStreetAddress(displayAddressBuilder);
            }

            BuildLocalityPart(displayAddressBuilder);

            return(displayAddressBuilder.ToString());
        }
        public string GenerateCompletionAddress(string locality, bool includeSiteName)
        {
            // full_address_string = (postal_address / street_address) locality_part
            var displayAddressBuilder = new StringBuilder();

            if (PostalDeliveryType.HasValue())
            {
                BuildPostalAddressPart(displayAddressBuilder);
            }
            else
            {
                BuildStreetAddress(displayAddressBuilder, includeSiteName);
            }

            BuildLocalityPart(displayAddressBuilder, locality);

            return(displayAddressBuilder.ToString());
        }
Example #4
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (Dpid != null)
         {
             hashCode = hashCode * 59 + Dpid.GetHashCode();
         }
         if (ThoroughfareNumber1 != null)
         {
             hashCode = hashCode * 59 + ThoroughfareNumber1.GetHashCode();
         }
         if (ThoroughfareNumber1Suffix != null)
         {
             hashCode = hashCode * 59 + ThoroughfareNumber1Suffix.GetHashCode();
         }
         if (ThoroughfareNumber2 != null)
         {
             hashCode = hashCode * 59 + ThoroughfareNumber2.GetHashCode();
         }
         if (ThoroughfareNumber2Suffix != null)
         {
             hashCode = hashCode * 59 + ThoroughfareNumber2Suffix.GetHashCode();
         }
         if (FlatUnitNumber != null)
         {
             hashCode = hashCode * 59 + FlatUnitNumber.GetHashCode();
         }
         if (FloorLevelNumber != null)
         {
             hashCode = hashCode * 59 + FloorLevelNumber.GetHashCode();
         }
         if (LotNumber != null)
         {
             hashCode = hashCode * 59 + LotNumber.GetHashCode();
         }
         if (BuildingName1 != null)
         {
             hashCode = hashCode * 59 + BuildingName1.GetHashCode();
         }
         if (BuildingName2 != null)
         {
             hashCode = hashCode * 59 + BuildingName2.GetHashCode();
         }
         if (StreetName != null)
         {
             hashCode = hashCode * 59 + StreetName.GetHashCode();
         }
         if (StreetType != null)
         {
             hashCode = hashCode * 59 + StreetType.GetHashCode();
         }
         if (StreetSuffix != null)
         {
             hashCode = hashCode * 59 + StreetSuffix.GetHashCode();
         }
         if (PostalDeliveryType != null)
         {
             hashCode = hashCode * 59 + PostalDeliveryType.GetHashCode();
         }
         if (PostalDeliveryNumber != null)
         {
             hashCode = hashCode * 59 + PostalDeliveryNumber.GetHashCode();
         }
         if (PostalDeliveryNumberPrefix != null)
         {
             hashCode = hashCode * 59 + PostalDeliveryNumberPrefix.GetHashCode();
         }
         if (PostalDeliveryNumberSuffix != null)
         {
             hashCode = hashCode * 59 + PostalDeliveryNumberSuffix.GetHashCode();
         }
         if (LocalityName != null)
         {
             hashCode = hashCode * 59 + LocalityName.GetHashCode();
         }
         if (Postcode != null)
         {
             hashCode = hashCode * 59 + Postcode.GetHashCode();
         }
         if (State != null)
         {
             hashCode = hashCode * 59 + State.GetHashCode();
         }
         return(hashCode);
     }
 }
Example #5
0
        /// <summary>
        /// Returns true if CommonPAFAddress instances are equal
        /// </summary>
        /// <param name="other">Instance of CommonPAFAddress to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(CommonPAFAddress other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Dpid == other.Dpid ||
                     Dpid != null &&
                     Dpid.Equals(other.Dpid)
                     ) &&
                 (
                     ThoroughfareNumber1 == other.ThoroughfareNumber1 ||
                     ThoroughfareNumber1 != null &&
                     ThoroughfareNumber1.Equals(other.ThoroughfareNumber1)
                 ) &&
                 (
                     ThoroughfareNumber1Suffix == other.ThoroughfareNumber1Suffix ||
                     ThoroughfareNumber1Suffix != null &&
                     ThoroughfareNumber1Suffix.Equals(other.ThoroughfareNumber1Suffix)
                 ) &&
                 (
                     ThoroughfareNumber2 == other.ThoroughfareNumber2 ||
                     ThoroughfareNumber2 != null &&
                     ThoroughfareNumber2.Equals(other.ThoroughfareNumber2)
                 ) &&
                 (
                     ThoroughfareNumber2Suffix == other.ThoroughfareNumber2Suffix ||
                     ThoroughfareNumber2Suffix != null &&
                     ThoroughfareNumber2Suffix.Equals(other.ThoroughfareNumber2Suffix)
                 ) &&
                 (
                     FlatUnitNumber == other.FlatUnitNumber ||
                     FlatUnitNumber != null &&
                     FlatUnitNumber.Equals(other.FlatUnitNumber)
                 ) &&
                 (
                     FloorLevelNumber == other.FloorLevelNumber ||
                     FloorLevelNumber != null &&
                     FloorLevelNumber.Equals(other.FloorLevelNumber)
                 ) &&
                 (
                     LotNumber == other.LotNumber ||
                     LotNumber != null &&
                     LotNumber.Equals(other.LotNumber)
                 ) &&
                 (
                     BuildingName1 == other.BuildingName1 ||
                     BuildingName1 != null &&
                     BuildingName1.Equals(other.BuildingName1)
                 ) &&
                 (
                     BuildingName2 == other.BuildingName2 ||
                     BuildingName2 != null &&
                     BuildingName2.Equals(other.BuildingName2)
                 ) &&
                 (
                     StreetName == other.StreetName ||
                     StreetName != null &&
                     StreetName.Equals(other.StreetName)
                 ) &&
                 (
                     StreetType == other.StreetType ||
                     StreetType != null &&
                     StreetType.Equals(other.StreetType)
                 ) &&
                 (
                     StreetSuffix == other.StreetSuffix ||
                     StreetSuffix != null &&
                     StreetSuffix.Equals(other.StreetSuffix)
                 ) &&
                 (
                     PostalDeliveryType == other.PostalDeliveryType ||
                     PostalDeliveryType != null &&
                     PostalDeliveryType.Equals(other.PostalDeliveryType)
                 ) &&
                 (
                     PostalDeliveryNumber == other.PostalDeliveryNumber ||
                     PostalDeliveryNumber != null &&
                     PostalDeliveryNumber.Equals(other.PostalDeliveryNumber)
                 ) &&
                 (
                     PostalDeliveryNumberPrefix == other.PostalDeliveryNumberPrefix ||
                     PostalDeliveryNumberPrefix != null &&
                     PostalDeliveryNumberPrefix.Equals(other.PostalDeliveryNumberPrefix)
                 ) &&
                 (
                     PostalDeliveryNumberSuffix == other.PostalDeliveryNumberSuffix ||
                     PostalDeliveryNumberSuffix != null &&
                     PostalDeliveryNumberSuffix.Equals(other.PostalDeliveryNumberSuffix)
                 ) &&
                 (
                     LocalityName == other.LocalityName ||
                     LocalityName != null &&
                     LocalityName.Equals(other.LocalityName)
                 ) &&
                 (
                     Postcode == other.Postcode ||
                     Postcode != null &&
                     Postcode.Equals(other.Postcode)
                 ) &&
                 (
                     State == other.State ||
                     State != null &&
                     State.Equals(other.State)
                 ));
        }