/// <summary> /// Overriden equal method /// </summary> /// <param name="obj"></param> /// <returns></returns> public override bool Equals(object obj) { if (obj is Address) { Address address = obj as Address; return(Address1.Equals(address.Address1, StringComparison.InvariantCultureIgnoreCase) && Address2.Equals(address.Address2, StringComparison.InvariantCultureIgnoreCase)); } return(false); }
public override bool Equals(object obj) { var casted = obj as Address; if (casted == null) { return(false); } return(Id == casted.Id && Address1.Equals(casted.Address1)); }
public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { var list = new List <ValidationResult>(); if (Address1 != null && Address2 != null) { if (Address1.Equals(Address2)) { list.Add(new ValidationResult("Address 1 and Address 2 are the same", new[] { "Address2" })); } } return(list); }
/// <summary> /// Compares two addresses for equality. /// </summary> /// <param name="Address1">An address.</param> /// <param name="Address2">Another address.</param> /// <returns>True if both match; False otherwise.</returns> public static Boolean operator ==(Address Address1, Address Address2) { // If both are null, or both are same instance, return true. if (Object.ReferenceEquals(Address1, Address2)) { return(true); } if (Address1 is null || Address2 is null) { return(false); } return(Address1.Equals(Address2)); }
/// <summary> /// Compares two addresses for equality. /// </summary> /// <param name="Address1">An address.</param> /// <param name="Address2">Another address.</param> /// <returns>True if both match; False otherwise.</returns> public static Boolean operator ==(Address Address1, Address Address2) { // If both are null, or both are same instance, return true. if (Object.ReferenceEquals(Address1, Address2)) { return(true); } // If one is null, but not both, return false. if (((Object)Address1 == null) || ((Object)Address2 == null)) { return(false); } return(Address1.Equals(Address2)); }
public override bool Equals(object obj) { var otherAddress = obj as Address; if (otherAddress == null || Address1 == null) { return(false); } if (!Address1.Equals(otherAddress.Address1)) { return(false); } if (Address2 != null) { if (!Address2.Equals(otherAddress.Address2)) { return(false); } } if (Suburb != null) { if (!Suburb.Equals(otherAddress.Suburb)) { return(false); } } if (Postcode != null) { if (!Postcode.Equals(otherAddress.Postcode)) { return(false); } } if (State != null) { if (!State.Equals(otherAddress.State)) { return(false); } } return(true); }
public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { //validate address if (Address1.Equals(Address2)) { yield return(new ValidationResult("Address 1 cannot be the same as Address 2")); } //validate state minimum if (State.Length != 2) { yield return(new ValidationResult("Enter a 2 digit State Code")); } //validate zipcode if (Zipcode.Length != 5) { yield return(new ValidationResult("Enter a 5 digit Zipcode")); } }
public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { //Validation 1 - Checking if Address 1 is the same as Address 2 if (Address1.Equals(Address2)) { yield return(new ValidationResult("Address2 cannot be the same as Address1", new[] { "Address2" })); } //Validation 2 - Checking if state is Two digits long if (State.Length != 2) { yield return(new ValidationResult("Enter a 2 digit state code", new[] { "State" })); } //Validation 3 - Zip code checking if (Zipcode.Length != 5) { yield return(new ValidationResult("Enter a 5 digit Zipcode", new[] { "Zipcode" })); } }
public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { if (Address1 != null && Address2 != null && Address1.Equals(Address2)) { yield return(new ValidationResult("Address2 cannot be the same as Address1.", new[] { "Address2" })); } if (State != null && State.Length != 2) { yield return(new ValidationResult("Enter a 2 digit State code.", new[] { "State" })); } if (Zipcode != null && Zipcode.Length != 5) { yield return(new ValidationResult("Enter a 5 digit Zipcode.", new[] { "Zipcode" })); } //throw new NotImplementedException(); }
public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { //validate zipcode is 5 digits if (Zipcode.Length != 5) { yield return(new ValidationResult("Please enter a 5 digit Zipcode.")); } //validate state is 2 digits if (State.Length > 2) { yield return(new ValidationResult("Please enter a 2 digit State code.")); } //check address 1 != address2 if (Address1.Equals(Address2)) { yield return(new ValidationResult("Address 2 cannot be the same as Address 1.")); } //throw new NotImplementedException(); }
public override bool Encode(ref byte[] buffer) { /* First : determine the total number of characters */ int NbBytes = count_nb_bytes(); /* Second : create the whole byte array */ int index = 0; int new_index; byte[] pl = new byte[NbBytes]; new_index = AddLine(pl, pl.Length, index, "BEGIN:VCARD", ""); if (new_index < 0) { Trace.WriteLine("Error generating 'VCard' object: after 'BEGIN'"); return(false); } index = new_index; new_index = AddLine(pl, pl.Length, index, "VERSION:3.0", ""); if (new_index < 0) { Trace.WriteLine("Error generating 'VCard' object: after 'VERSION'"); return(false); } index = new_index; string name = _first_name + " " + _family_name; new_index = AddLine(pl, pl.Length, index, "FN:", name); if (new_index < 0) { Trace.WriteLine("Error generating 'VCard' object: after 'FN'"); return(false); } index = new_index; if (!Nickname.Equals("")) { new_index = AddLine(pl, pl.Length, index, "NICKNAME:", Nickname); if (new_index < 0) { Trace.WriteLine("Error generating 'VCard' object: after 'Nickname'"); return(false); } index = new_index; } DateTime dateBirthday; if ((!Birthday.Equals("")) && (DateTime.TryParse(Birthday, out dateBirthday))) { string Bday = convert_into_vcard_date(Birthday); new_index = AddLine(pl, pl.Length, index, "BDAY:", Bday); if (new_index < 0) { Trace.WriteLine("Error generating 'VCard' object: after 'Birthday'"); return(false); } index = new_index; } if (!(Address1.Equals("")) || !(Address2.Equals("")) || !(Town.Equals("")) || !(Region_State.Equals("")) || !(Post_Code.Equals("")) || !(Country.Equals("")) ) { string addr_line = Address1 + ";" + Address2 + ";" + Town + ";" + Region_State + ";" + Post_Code + ";" + Country; new_index = AddLine(pl, pl.Length, index, "ADR:;", addr_line); if (new_index < 0) { Trace.WriteLine("Error generating 'VCard' object: after 'Address'"); return(false); } index = new_index; } if (!(Pro_Address1.Equals("")) || !(Pro_Address2.Equals("")) || !(Pro_Town.Equals("")) || !(Pro_Region_State.Equals("")) || !(Pro_Post_Code.Equals("")) || !(Pro_Country.Equals("")) ) { string pro_addr_line = Pro_Address1 + ";" + Pro_Address2 + ";" + Pro_Town + ";" + Pro_Region_State + ";" + Pro_Post_Code + ";" + Pro_Country; new_index = AddLine(pl, pl.Length, index, "ADR;TYPE=work:;", pro_addr_line); if (new_index < 0) { Trace.WriteLine("Error generating 'VCard' object: after 'Professional Address'"); return(false); } index = new_index; } if (!Home_phone.Equals("")) { new_index = AddLine(pl, pl.Length, index, "TEL;TYPE=home:", Home_phone); if (new_index < 0) { Trace.WriteLine("Error generating 'VCard' object: after 'TEL;TYPE=home'"); return(false); } index = new_index; } if (!Business_phone.Equals("")) { new_index = AddLine(pl, pl.Length, index, "TEL;TYPE=work:", Business_phone); if (new_index < 0) { Trace.WriteLine("Error generating 'VCard' object: after 'TEL;TYPE=work'"); return(false); } index = new_index; } if (!Cell_phone.Equals("")) { new_index = AddLine(pl, pl.Length, index, "TEL;TYPE=cell:", Cell_phone); if (new_index < 0) { Trace.WriteLine("Error generating 'VCard' object: after 'TEL;TYPE=cell'"); return(false); } index = new_index; } if (!Pager.Equals("")) { new_index = AddLine(pl, pl.Length, index, "TEL;TYPE=pager:", Pager); if (new_index < 0) { Trace.WriteLine("Error generating 'VCard' object: after 'TEL;TYPE=pager'"); return(false); } index = new_index; } if (!Fax.Equals("")) { new_index = AddLine(pl, pl.Length, index, "TEL;TYPE=fax:", Fax); if (new_index < 0) { Trace.WriteLine("Error generating 'VCard' object: after 'TEL;TYPE=fax'"); return(false); } index = new_index; } if (!Email.Equals("")) { if (Email_alternative.Equals("")) { new_index = AddLine(pl, pl.Length, index, "EMAIL:", Email); if (new_index < 0) { Trace.WriteLine("Error generating 'VCard' object: after 'EMAIL'"); return(false); } index = new_index; } else { /* Two E-mails to add */ new_index = AddLine(pl, pl.Length, index, "EMAIL;PREF=1:", Email); if (new_index < 0) { Trace.WriteLine("Error generating 'VCard' object: after 'EMAIL;PREF=1'"); return(false); } index = new_index; new_index = AddLine(pl, pl.Length, index, "EMAIL;PREF=2:", Email_alternative); if (new_index < 0) { Trace.WriteLine("Error generating 'VCard' object: after 'EMAIL;PREF=2'"); return(false); } index = new_index; } } if (!Title.Equals("")) { new_index = AddLine(pl, pl.Length, index, "TITLE:", Title); if (new_index < 0) { Trace.WriteLine("Error generating 'VCard' object: after 'TITLE'"); return(false); } index = new_index; } if (!Role.Equals("")) { new_index = AddLine(pl, pl.Length, index, "ROLE:", Role); if (new_index < 0) { Trace.WriteLine("Error generating 'VCard' object: after 'ROLE'"); return(false); } index = new_index; } if (!Company.Equals("")) { new_index = AddLine(pl, pl.Length, index, "ORG:", Company); if (new_index < 0) { Trace.WriteLine("Error generating 'VCard' object: after 'ORG'"); return(false); } index = new_index; } if (!_photo.Equals("")) { new_index = AddLine(pl, pl.Length, index, "PHOTO;ENCODING=BASE64;TYPE=JPEG:", _photo); if (new_index < 0) { Trace.WriteLine("Error generating 'VCard' object: after 'PHOTO'"); return(false); } index = new_index; } new_index = AddLine(pl, pl.Length, index, "END:VCARD", ""); _payload = pl; return(base.Encode(ref buffer)); }
private int count_nb_bytes() { /* All the ASCII strings in the VCard must be separated by 0x0D0A, which represent 2 characters */ int NbBytes = 0; NbBytes = "BEGIN:VCARD".Length + 2 + "VERSION:3.0".Length + 2; NbBytes += "FN:".Length + First_name.Length + 1 + Family_name.Length + 2; /* 1 is for "space" */ if (!Nickname.Equals("")) { NbBytes += "NICKNAME:".Length + Nickname.Length + 2; } /* Birthday with 8 characters: yyyymmdd */ DateTime dateBirthday; if ((!Birthday.Equals("")) && (DateTime.TryParse(Birthday, out dateBirthday))) { NbBytes += "BDAY:".Length + 8 + 2; } /* Home address in 6 fields, separated by a ';' */ /* The PO Box is discarded, which explains the first ';' */ if (!(Address1.Equals("")) || !(Address2.Equals("")) || !(Town.Equals("")) || !(Region_State.Equals("")) || !(Post_Code.Equals("")) || !(Country.Equals("")) ) { NbBytes += "ADR:;".Length + Address1.Length + 1 + Address2.Length + 1 + Town.Length + 1 + Region_State.Length + 1 + Post_Code.Length + 1 + Country.Length + 2; } /* Work address in 6 fields, separated by a ';' */ /* The PO Box is discarded, which explains the first ';' */ if (!(Pro_Address1.Equals("")) || !(Pro_Address2.Equals("")) || !(Pro_Town.Equals("")) || !(Pro_Region_State.Equals("")) || !(Pro_Post_Code.Equals("")) || !(Pro_Country.Equals("")) ) { NbBytes += "ADR;TYPE=work:;".Length + Pro_Address1.Length + 1 + Pro_Address2.Length + 1 + Pro_Town.Length + 1 + Pro_Region_State.Length + 1 + Pro_Post_Code.Length + 1 + Pro_Country.Length + 2; } if (!Home_phone.Equals("")) { NbBytes += "TEL;TYPE=home:".Length + Home_phone.Length + 2; } if (!Business_phone.Equals("")) { NbBytes += "TEL;TYPE=work:".Length + Business_phone.Length + 2; } if (!Cell_phone.Equals("")) { NbBytes += "TEL;TYPE=cell:".Length + Cell_phone.Length + 2; } if (!Fax.Equals("")) { NbBytes += "TEL;TYPE=fax:".Length + Fax.Length + 2; } if (!Pager.Equals("")) { NbBytes += "TEL;TYPE=pager:".Length + Pager.Length + 2; } if (!Email.Equals("")) { if (Email_alternative.Equals("")) { NbBytes += "EMAIL:".Length + Email.Length + 2; } else { /* TWO EMAILS : PREF=1 and PREF=2 */ NbBytes += "EMAIL;PREF=1:".Length + Email.Length + 2 + "EMAIL;PREF=2:".Length + Email_alternative.Length + 2; } } if (!Title.Equals("")) { NbBytes += "TITLE:".Length + Title.Length + 2; } if (!Role.Equals("")) { NbBytes += "ROLE:".Length + Role.Length + 2; } if (!Company.Equals("")) { NbBytes += "ORG:".Length + Company.Length + 2; } if (!_photo.Equals("")) { NbBytes += "PHOTO;ENCODING=BASE64;TYPE=JPEG:".Length + _photo.Length + 2; } NbBytes += "END:VCARD".Length + 2; return(NbBytes); }
/// <summary> /// Returns true if Contact instances are equal /// </summary> /// <param name="other">Instance of Contact to be compared</param> /// <returns>Boolean</returns> public bool Equals(Contact other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Id == other.Id || Id.Equals(other.Id) ) && ( GivenName == other.GivenName || GivenName != null && GivenName.Equals(other.GivenName) ) && ( Surname == other.Surname || Surname != null && Surname.Equals(other.Surname) ) && ( OrganizationName == other.OrganizationName || OrganizationName != null && OrganizationName.Equals(other.OrganizationName) ) && ( Role == other.Role || Role != null && Role.Equals(other.Role) ) && ( Notes == other.Notes || Notes != null && Notes.Equals(other.Notes) ) && ( EmailAddress == other.EmailAddress || EmailAddress != null && EmailAddress.Equals(other.EmailAddress) ) && ( WorkPhoneNumber == other.WorkPhoneNumber || WorkPhoneNumber != null && WorkPhoneNumber.Equals(other.WorkPhoneNumber) ) && ( MobilePhoneNumber == other.MobilePhoneNumber || MobilePhoneNumber != null && MobilePhoneNumber.Equals(other.MobilePhoneNumber) ) && ( FaxPhoneNumber == other.FaxPhoneNumber || FaxPhoneNumber != null && FaxPhoneNumber.Equals(other.FaxPhoneNumber) ) && ( Address1 == other.Address1 || Address1 != null && Address1.Equals(other.Address1) ) && ( Address2 == other.Address2 || Address2 != null && Address2.Equals(other.Address2) ) && ( City == other.City || City != null && City.Equals(other.City) ) && ( Province == other.Province || Province != null && Province.Equals(other.Province) ) && ( PostalCode == other.PostalCode || PostalCode != null && PostalCode.Equals(other.PostalCode) )); }
/// <summary> /// Returns true if Address instances are equal /// </summary> /// <param name="other">Instance of Address to be compared</param> /// <returns>Boolean</returns> public bool Equals(Address other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( ReferenceNumber == other.ReferenceNumber || ReferenceNumber != null && ReferenceNumber.Equals(other.ReferenceNumber) ) && ( FirstName == other.FirstName || FirstName != null && FirstName.Equals(other.FirstName) ) && ( LastName == other.LastName || LastName != null && LastName.Equals(other.LastName) ) && ( Address1 == other.Address1 || Address1 != null && Address1.Equals(other.Address1) ) && ( Address2 == other.Address2 || Address2 != null && Address2.Equals(other.Address2) ) && ( City == other.City || City != null && City.Equals(other.City) ) && ( State == other.State || State != null && State.Equals(other.State) ) && ( CountryCode == other.CountryCode || CountryCode != null && CountryCode.Equals(other.CountryCode) ) && ( PostalCode == other.PostalCode || PostalCode != null && PostalCode.Equals(other.PostalCode) ) && ( PhoneNumber == other.PhoneNumber || PhoneNumber != null && PhoneNumber.Equals(other.PhoneNumber) )); }
/// <summary> /// Returns true if Owner instances are equal /// </summary> /// <param name="other">Instance of Owner to be compared</param> /// <returns>Boolean</returns> public bool Equals(Owner other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Id == other.Id || Id.Equals(other.Id) ) && ( OwnerCode == other.OwnerCode || OwnerCode != null && OwnerCode.Equals(other.OwnerCode) ) && ( OrganizationName == other.OrganizationName || OrganizationName != null && OrganizationName.Equals(other.OrganizationName) ) && ( MeetsResidency == other.MeetsResidency || MeetsResidency.Equals(other.MeetsResidency) ) && ( LocalArea == other.LocalArea || LocalArea != null && LocalArea.Equals(other.LocalArea) ) && ( Status == other.Status || Status != null && Status.Equals(other.Status) ) && ( StatusComment == other.StatusComment || StatusComment != null && StatusComment.Equals(other.StatusComment) ) && ( DoingBusinessAs == other.DoingBusinessAs || DoingBusinessAs != null && DoingBusinessAs.Equals(other.DoingBusinessAs) ) && ( RegisteredCompanyNumber == other.RegisteredCompanyNumber || RegisteredCompanyNumber != null && RegisteredCompanyNumber.Equals(other.RegisteredCompanyNumber) ) && ( PrimaryContact == other.PrimaryContact || PrimaryContact != null && PrimaryContact.Equals(other.PrimaryContact) ) && ( IsMaintenanceContractor == other.IsMaintenanceContractor || IsMaintenanceContractor != null && IsMaintenanceContractor.Equals(other.IsMaintenanceContractor) ) && ( WorkSafeBCPolicyNumber == other.WorkSafeBCPolicyNumber || WorkSafeBCPolicyNumber != null && WorkSafeBCPolicyNumber.Equals(other.WorkSafeBCPolicyNumber) ) && ( WorkSafeBCExpiryDate == other.WorkSafeBCExpiryDate || WorkSafeBCExpiryDate != null && WorkSafeBCExpiryDate.Equals(other.WorkSafeBCExpiryDate) ) && ( GivenName == other.GivenName || GivenName != null && GivenName.Equals(other.GivenName) ) && ( Surname == other.Surname || Surname != null && Surname.Equals(other.Surname) ) && ( Address1 == other.Address1 || Address1 != null && Address1.Equals(other.Address1) ) && ( Address2 == other.Address2 || Address2 != null && Address2.Equals(other.Address2) ) && ( City == other.City || City != null && City.Equals(other.City) ) && ( Province == other.Province || Province != null && Province.Equals(other.Province) ) && ( PostalCode == other.PostalCode || PostalCode != null && PostalCode.Equals(other.PostalCode) ) && ( CGLEndDate == other.CGLEndDate || CGLEndDate != null && CGLEndDate.Equals(other.CGLEndDate) ) && ( CglPolicyNumber == other.CglPolicyNumber || CglPolicyNumber != null && CglPolicyNumber.Equals(other.CglPolicyNumber) ) && ( ArchiveCode == other.ArchiveCode || ArchiveCode != null && ArchiveCode.Equals(other.ArchiveCode) ) && ( ArchiveReason == other.ArchiveReason || ArchiveReason != null && ArchiveReason.Equals(other.ArchiveReason) ) && ( ArchiveDate == other.ArchiveDate || ArchiveDate != null && ArchiveDate.Equals(other.ArchiveDate) ) && ( Contacts == other.Contacts || Contacts != null && Contacts.SequenceEqual(other.Contacts) ) && ( Notes == other.Notes || Notes != null && Notes.SequenceEqual(other.Notes) ) && ( Attachments == other.Attachments || Attachments != null && Attachments.SequenceEqual(other.Attachments) ) && ( History == other.History || History != null && History.SequenceEqual(other.History) ) && ( EquipmentList == other.EquipmentList || EquipmentList != null && EquipmentList.SequenceEqual(other.EquipmentList) )); }