/// <summary> /// Create unique hash /// </summary> /// <param name="endpoint"></param> /// <returns></returns> public static int CreateConsistentHash(this EndpointModel endpoint) { var hashCode = -1971667340; hashCode = (hashCode * -1521134295) + endpoint.GetAllUrls().SequenceGetHashSafe(); hashCode = (hashCode * -1521134295) + endpoint.Certificate.SequenceGetHashSafe(); hashCode = (hashCode * -1521134295) + EqualityComparer <string> .Default.GetHashCode(endpoint.SecurityPolicy); hashCode = (hashCode * -1521134295) + EqualityComparer <SecurityMode?> .Default.GetHashCode( endpoint.SecurityMode ?? SecurityMode.Best); return(hashCode); }
/// <summary> /// Equality comparison /// </summary> /// <param name="model"></param> /// <param name="that"></param> /// <returns></returns> public static bool IsSameAs(this EndpointModel model, EndpointModel that) { if (model == that) { return(true); } if (model == null || that == null) { return(false); } if (!that.HasSameSecurityProperties(model)) { return(false); } if (!that.GetAllUrls().SequenceEqualsSafe(model.GetAllUrls())) { return(false); } return(true); }