示例#1
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            if (obj == this)
            {
                return(true);
            }

            return(obj is Address other &&
                   ((AddressLine1 == null && other.AddressLine1 == null) || (AddressLine1?.Equals(other.AddressLine1) == true)) &&
                   ((AddressLine2 == null && other.AddressLine2 == null) || (AddressLine2?.Equals(other.AddressLine2) == true)) &&
                   ((AddressLine3 == null && other.AddressLine3 == null) || (AddressLine3?.Equals(other.AddressLine3) == true)) &&
                   ((Locality == null && other.Locality == null) || (Locality?.Equals(other.Locality) == true)) &&
                   ((Sublocality == null && other.Sublocality == null) || (Sublocality?.Equals(other.Sublocality) == true)) &&
                   ((Sublocality2 == null && other.Sublocality2 == null) || (Sublocality2?.Equals(other.Sublocality2) == true)) &&
                   ((Sublocality3 == null && other.Sublocality3 == null) || (Sublocality3?.Equals(other.Sublocality3) == true)) &&
                   ((AdministrativeDistrictLevel1 == null && other.AdministrativeDistrictLevel1 == null) || (AdministrativeDistrictLevel1?.Equals(other.AdministrativeDistrictLevel1) == true)) &&
                   ((AdministrativeDistrictLevel2 == null && other.AdministrativeDistrictLevel2 == null) || (AdministrativeDistrictLevel2?.Equals(other.AdministrativeDistrictLevel2) == true)) &&
                   ((AdministrativeDistrictLevel3 == null && other.AdministrativeDistrictLevel3 == null) || (AdministrativeDistrictLevel3?.Equals(other.AdministrativeDistrictLevel3) == true)) &&
                   ((PostalCode == null && other.PostalCode == null) || (PostalCode?.Equals(other.PostalCode) == true)) &&
                   ((Country == null && other.Country == null) || (Country?.Equals(other.Country) == true)) &&
                   ((FirstName == null && other.FirstName == null) || (FirstName?.Equals(other.FirstName) == true)) &&
                   ((LastName == null && other.LastName == null) || (LastName?.Equals(other.LastName) == true)) &&
                   ((Organization == null && other.Organization == null) || (Organization?.Equals(other.Organization) == true)));
        }
        /// <summary>
        /// Returns true if CommonSimpleAddress instances are equal
        /// </summary>
        /// <param name="other">Instance of CommonSimpleAddress to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(CommonSimpleAddress other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     MailingName == other.MailingName ||
                     MailingName != null &&
                     MailingName.Equals(other.MailingName)
                     ) &&
                 (
                     AddressLine1 == other.AddressLine1 ||
                     AddressLine1 != null &&
                     AddressLine1.Equals(other.AddressLine1)
                 ) &&
                 (
                     AddressLine2 == other.AddressLine2 ||
                     AddressLine2 != null &&
                     AddressLine2.Equals(other.AddressLine2)
                 ) &&
                 (
                     AddressLine3 == other.AddressLine3 ||
                     AddressLine3 != null &&
                     AddressLine3.Equals(other.AddressLine3)
                 ) &&
                 (
                     Postcode == other.Postcode ||
                     Postcode != null &&
                     Postcode.Equals(other.Postcode)
                 ) &&
                 (
                     City == other.City ||
                     City != null &&
                     City.Equals(other.City)
                 ) &&
                 (
                     State == other.State ||
                     State != null &&
                     State.Equals(other.State)
                 ) &&
                 (
                     Country == other.Country ||
                     Country != null &&
                     Country.Equals(other.Country)
                 ));
        }
示例#3
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (_postcode != null ? _postcode.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (AddressLine1 != null ? AddressLine1.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (AddressLine2 != null ? AddressLine2.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (AddressLine3 != null ? AddressLine3.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (AddressLine4 != null ? AddressLine4.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Uprn != null ? Uprn.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (GeoPoint != null ? GeoPoint.GetHashCode() : 0);
         return(hashCode);
     }
 }
        public List <string> GetList()
        {
            var list = new List <string>();

            if (!string.IsNullOrWhiteSpace(AddressLine1))
            {
                list.Add(AddressLine1.TrimI());
            }

            if (!string.IsNullOrWhiteSpace(AddressLine2))
            {
                list.Add(AddressLine2.TrimI());
            }

            if (!string.IsNullOrWhiteSpace(AddressLine3))
            {
                list.Add(AddressLine3.TrimI());
            }

            if (!string.IsNullOrWhiteSpace(City))
            {
                list.Add(City.TrimI());
            }

            if (!string.IsNullOrWhiteSpace(County))
            {
                list.Add(County.TrimI());
            }

            if (!string.IsNullOrWhiteSpace(Country))
            {
                list.Add(Country.TrimI());
            }

            if (!string.IsNullOrWhiteSpace(PostalCode))
            {
                list.Add(PostalCode.TrimI());
            }

            if (!string.IsNullOrWhiteSpace(PoBox))
            {
                list.Add(PoBox.TrimI());
            }

            return(list);
        }
示例#5
0
        public override int GetHashCode()
        {
            unchecked
            {
                const int hashBase   = (int)2166136261;
                const int multiplier = 16777619;

                int hash = hashBase;
                hash = (hash * multiplier) ^ (ContactName is null ? 0 : ContactName.GetHashCode());
                hash = (hash * multiplier) ^ (Department is null ? 0 : Department.GetHashCode());
                hash = (hash * multiplier) ^ (Organisation is null ? 0 : Organisation.GetHashCode());
                hash = (hash * multiplier) ^ (AddressLine1 is null ? 0 : AddressLine1.GetHashCode());
                hash = (hash * multiplier) ^ (AddressLine2 is null ? 0 : AddressLine2.GetHashCode());
                hash = (hash * multiplier) ^ (AddressLine3 is null ? 0 : AddressLine3.GetHashCode());
                hash = (hash * multiplier) ^ (City is null ? 0 : City.GetHashCode());
                hash = (hash * multiplier) ^ (PostCode is null ? 0 : PostCode.GetHashCode());

                return(hash);
            }
        }
 /// <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 (MailingName != null)
         {
             hashCode = hashCode * 59 + MailingName.GetHashCode();
         }
         if (AddressLine1 != null)
         {
             hashCode = hashCode * 59 + AddressLine1.GetHashCode();
         }
         if (AddressLine2 != null)
         {
             hashCode = hashCode * 59 + AddressLine2.GetHashCode();
         }
         if (AddressLine3 != null)
         {
             hashCode = hashCode * 59 + AddressLine3.GetHashCode();
         }
         if (Postcode != null)
         {
             hashCode = hashCode * 59 + Postcode.GetHashCode();
         }
         if (City != null)
         {
             hashCode = hashCode * 59 + City.GetHashCode();
         }
         if (State != null)
         {
             hashCode = hashCode * 59 + State.GetHashCode();
         }
         if (Country != null)
         {
             hashCode = hashCode * 59 + Country.GetHashCode();
         }
         return(hashCode);
     }
 }
示例#7
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (AddressLine1.Length != 0)
            {
                hash ^= AddressLine1.GetHashCode();
            }
            if (AddressLine2.Length != 0)
            {
                hash ^= AddressLine2.GetHashCode();
            }
            if (AddressLine3.Length != 0)
            {
                hash ^= AddressLine3.GetHashCode();
            }
            if (City.Length != 0)
            {
                hash ^= City.GetHashCode();
            }
            if (State.Length != 0)
            {
                hash ^= State.GetHashCode();
            }
            if (ZipCode.Length != 0)
            {
                hash ^= ZipCode.GetHashCode();
            }
            if (CountryCode.Length != 0)
            {
                hash ^= CountryCode.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
示例#8
0
        /// <summary>
        /// Get the GEDCOM 5.5 lines for the data in this object.
        /// Lines start at the given level
        /// </summary>
        /// <param name="sw">
        /// A <see cref="TextWriter"/>
        /// </param>
        /// <param name="level">
        /// A <see cref="int"/>
        /// </param>
        public void Output(TextWriter sw, int level)
        {
            sw.Write(Environment.NewLine);
            sw.Write(Util.IntToString(level));
            sw.Write(" ADDR");

            if (!string.IsNullOrEmpty(AddressLine))
            {
                sw.Write(" ");

                Util.SplitLineText(sw, AddressLine, level, 60, 3, true);
            }

            string levelStr     = null;
            string levelPlusOne = null;

            if (!string.IsNullOrEmpty(AddressLine1))
            {
                if (levelPlusOne == null)
                {
                    levelPlusOne = Util.IntToString(level + 1);
                }

                string line = AddressLine1.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelPlusOne);
                sw.Write(" ADR1 ");
                if (line.Length <= 60)
                {
                    sw.Write(AddressLine1);
                }
                else
                {
                    sw.Write(line.Substring(0, 60));
                    System.Diagnostics.Debug.WriteLine("Truncating AddressLine1");
                }
            }

            if (!string.IsNullOrEmpty(AddressLine2))
            {
                if (levelPlusOne == null)
                {
                    levelPlusOne = Util.IntToString(level + 1);
                }

                string line = AddressLine2.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelPlusOne);
                sw.Write(" ADR2 ");
                if (line.Length <= 60)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 60));
                    System.Diagnostics.Debug.WriteLine("Truncating AddressLine2");
                }
            }

            if (!string.IsNullOrEmpty(AddressLine3))
            {
                if (levelPlusOne == null)
                {
                    levelPlusOne = Util.IntToString(level + 1);
                }

                string line = AddressLine3.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelPlusOne);
                sw.Write(" ADR3 ");
                if (line.Length <= 60)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 60));
                    System.Diagnostics.Debug.WriteLine("Truncating AddressLine3");
                }
            }

            if (!string.IsNullOrEmpty(City))
            {
                if (levelPlusOne == null)
                {
                    levelPlusOne = Util.IntToString(level + 1);
                }

                string line = City.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelPlusOne);
                sw.Write(" CITY ");
                if (line.Length <= 60)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 60));
                    System.Diagnostics.Debug.WriteLine("Truncating City");
                }
            }

            if (!string.IsNullOrEmpty(State))
            {
                if (levelPlusOne == null)
                {
                    levelPlusOne = Util.IntToString(level + 1);
                }

                string line = State.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelPlusOne);
                sw.Write(" STAE ");
                if (line.Length <= 60)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 60));
                    System.Diagnostics.Debug.WriteLine("Truncating State");
                }
            }

            if (!string.IsNullOrEmpty(PostCode))
            {
                if (levelPlusOne == null)
                {
                    levelPlusOne = Util.IntToString(level + 1);
                }

                string line = PostCode.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelPlusOne);
                sw.Write(" POST ");
                if (line.Length <= 10)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 10));
                    System.Diagnostics.Debug.WriteLine("Truncating PostCode");
                }
            }

            if (!string.IsNullOrEmpty(Country))
            {
                if (levelPlusOne == null)
                {
                    levelPlusOne = Util.IntToString(level + 1);
                }

                string line = Country.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelPlusOne);
                sw.Write(" CTRY ");
                if (line.Length <= 60)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 60));
                    System.Diagnostics.Debug.WriteLine("Truncating Country");
                }
            }

            if (!string.IsNullOrEmpty(Phone1))
            {
                if (levelStr == null)
                {
                    levelStr = Util.IntToString(level);
                }

                string line = Phone1.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelStr);
                sw.Write(" PHON ");
                if (line.Length <= 25)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 25));
                    System.Diagnostics.Debug.WriteLine("Truncating Phone1");
                }
            }

            if (!string.IsNullOrEmpty(Phone2))
            {
                if (levelStr == null)
                {
                    levelStr = Util.IntToString(level);
                }

                string line = Phone2.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelStr);
                sw.Write(" PHON ");
                if (line.Length <= 25)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 25));
                    System.Diagnostics.Debug.WriteLine("Truncating Phone2");
                }
            }

            if (!string.IsNullOrEmpty(Phone3))
            {
                if (levelStr == null)
                {
                    levelStr = Util.IntToString(level);
                }

                string line = Phone3.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelStr);
                sw.Write(" PHON ");
                if (line.Length <= 25)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 25));
                    System.Diagnostics.Debug.WriteLine("Truncating Phone3");
                }
            }

            if (!string.IsNullOrEmpty(Fax1))
            {
                if (levelStr == null)
                {
                    levelStr = Util.IntToString(level);
                }

                string line = Fax1.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelStr);
                sw.Write(" FAX ");
                if (line.Length <= 60)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 60));
                    System.Diagnostics.Debug.WriteLine("Truncating Fax1");
                }
            }

            if (!string.IsNullOrEmpty(Fax2))
            {
                if (levelStr == null)
                {
                    levelStr = Util.IntToString(level);
                }

                string line = Fax2.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelStr);
                sw.Write(" FAX ");
                if (line.Length <= 60)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 60));
                    System.Diagnostics.Debug.WriteLine("Truncating Fax2");
                }
            }

            if (!string.IsNullOrEmpty(Fax3))
            {
                if (levelStr == null)
                {
                    levelStr = Util.IntToString(level);
                }

                string line = Fax3.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelStr);
                sw.Write(" FAX ");
                if (line.Length <= 60)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 60));
                    System.Diagnostics.Debug.WriteLine("Truncating Fax3");
                }
            }

            if (!string.IsNullOrEmpty(Email1))
            {
                if (levelStr == null)
                {
                    levelStr = Util.IntToString(level);
                }

                string line = Email1.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelStr);
                sw.Write(" EMAIL ");
                if (line.Length <= 120)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 120));
                    System.Diagnostics.Debug.WriteLine("Truncating Email1");
                }
            }

            if (!string.IsNullOrEmpty(Email2))
            {
                if (levelStr == null)
                {
                    levelStr = Util.IntToString(level);
                }

                string line = Email2.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelStr);
                sw.Write(" EMAIL ");
                if (line.Length <= 120)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 120));
                    System.Diagnostics.Debug.WriteLine("Truncating Email2");
                }
            }

            if (!string.IsNullOrEmpty(Email3))
            {
                if (levelStr == null)
                {
                    levelStr = Util.IntToString(level);
                }

                string line = Email3.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelStr);
                sw.Write(" EMAIL ");
                if (line.Length <= 120)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 120));
                    System.Diagnostics.Debug.WriteLine("Truncating Email3");
                }
            }

            if (!string.IsNullOrEmpty(Www1))
            {
                if (levelStr == null)
                {
                    levelStr = Util.IntToString(level);
                }

                string line = Www1.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelStr);
                sw.Write(" WWW ");
                if (line.Length <= 120)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 120));
                    System.Diagnostics.Debug.WriteLine("Truncating Www1");
                }
            }

            if (!string.IsNullOrEmpty(Www2))
            {
                if (levelStr == null)
                {
                    levelStr = Util.IntToString(level);
                }

                string line = Www2.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelStr);
                sw.Write(" WWW ");
                if (line.Length <= 120)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 120));
                    System.Diagnostics.Debug.WriteLine("Truncating Www2");
                }
            }

            if (!string.IsNullOrEmpty(Www3))
            {
                if (levelStr == null)
                {
                    levelStr = Util.IntToString(level);
                }

                string line = Www3.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelStr);
                sw.Write(" WWW ");
                if (line.Length <= 120)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 120));
                    System.Diagnostics.Debug.WriteLine("Truncating Www3");
                }
            }
        }
示例#9
0
        public override int GetHashCode()
        {
            int hashCode = -1623438759;

            if (AddressLine1 != null)
            {
                hashCode += AddressLine1.GetHashCode();
            }

            if (AddressLine2 != null)
            {
                hashCode += AddressLine2.GetHashCode();
            }

            if (AddressLine3 != null)
            {
                hashCode += AddressLine3.GetHashCode();
            }

            if (Locality != null)
            {
                hashCode += Locality.GetHashCode();
            }

            if (Sublocality != null)
            {
                hashCode += Sublocality.GetHashCode();
            }

            if (Sublocality2 != null)
            {
                hashCode += Sublocality2.GetHashCode();
            }

            if (Sublocality3 != null)
            {
                hashCode += Sublocality3.GetHashCode();
            }

            if (AdministrativeDistrictLevel1 != null)
            {
                hashCode += AdministrativeDistrictLevel1.GetHashCode();
            }

            if (AdministrativeDistrictLevel2 != null)
            {
                hashCode += AdministrativeDistrictLevel2.GetHashCode();
            }

            if (AdministrativeDistrictLevel3 != null)
            {
                hashCode += AdministrativeDistrictLevel3.GetHashCode();
            }

            if (PostalCode != null)
            {
                hashCode += PostalCode.GetHashCode();
            }

            if (Country != null)
            {
                hashCode += Country.GetHashCode();
            }

            if (FirstName != null)
            {
                hashCode += FirstName.GetHashCode();
            }

            if (LastName != null)
            {
                hashCode += LastName.GetHashCode();
            }

            if (Organization != null)
            {
                hashCode += Organization.GetHashCode();
            }

            return(hashCode);
        }