///<summary> /// Returns a value indicating whether this instance is equal to a specified object using value semantics. ///</summary> ///<param name="toObject">An object to compare to this instance.</param> ///<returns>true if toObject is a <see cref="UtilsBase"/> and has the same value as this instance; otherwise, false.</returns> public virtual bool Equals(UtilsBase toObject) { if (toObject == null) { return(false); } return(ValueEquals(this, toObject)); }
/// <summary> /// Initializes a new instance of the UtilsKey class. /// </summary> public UtilsKey(UtilsBase entity) { this.Entity = entity; #region Init Properties if (entity != null) { this.Id = entity.Id; } #endregion }
///<summary> /// Determines whether the specified <see cref="UtilsBase"/> instances are considered equal using value semantics. ///</summary> ///<param name="Object1">The first <see cref="UtilsBase"/> to compare.</param> ///<param name="Object2">The second <see cref="UtilsBase"/> to compare. </param> ///<returns>true if Object1 is the same instance as Object2 or if both are null references or if objA.Equals(objB) returns true; otherwise, false.</returns> public static bool ValueEquals(UtilsBase Object1, UtilsBase Object2) { // both are null if (Object1 == null && Object2 == null) { return(true); } // one or the other is null, but not both if (Object1 == null ^ Object2 == null) { return(false); } bool equal = true; if (Object1.Id != Object2.Id) { equal = false; } if (Object1.Name != null && Object2.Name != null) { if (Object1.Name != Object2.Name) { equal = false; } } else if (Object1.Name == null ^ Object2.Name == null) { equal = false; } if (Object1.Description != null && Object2.Description != null) { if (Object1.Description != Object2.Description) { equal = false; } } else if (Object1.Description == null ^ Object2.Description == null) { equal = false; } if (Object1.Subname != null && Object2.Subname != null) { if (Object1.Subname != Object2.Subname) { equal = false; } } else if (Object1.Subname == null ^ Object2.Subname == null) { equal = false; } if (Object1.Status != null && Object2.Status != null) { if (Object1.Status != Object2.Status) { equal = false; } } else if (Object1.Status == null ^ Object2.Status == null) { equal = false; } return(equal); }