/// <summary> /// Returns true if the given attribute collection contains the same attributes than the given collection. /// </summary> public static bool ContainsSame(this IReadonlyAttributeCollection attributes, IReadonlyAttributeCollection other, params string[] exclude) { var attributesCount = 0; var otherCount = 0; if (attributes != null) { foreach (var a in attributes) { if (exclude.Contains(a.Key)) { continue; } attributesCount++; if (!other.Contains(a.Key, a.Value)) { return(false); } } } if (other != null) { foreach (var a in other) { if (exclude.Contains(a.Key)) { continue; } otherCount++; if (!attributes.Contains(a.Key, a.Value)) { return(false); } } } return(attributesCount == otherCount); }
/// <summary> /// Returns true if the given attribute collection contains the same attributes than the given collection. /// </summary> public static bool ContainsSame(this IReadonlyAttributeCollection attributes, IReadonlyAttributeCollection other) { if (attributes == null && other == null) { return(true); } else if (attributes == null) { return(other.Count == 0); } else if (other == null) { return(attributes.Count == 0); } if (attributes.Count != other.Count) { return(false); } foreach (var a in attributes) { if (!other.Contains(a.Key, a.Value)) { return(false); } } foreach (var a in other) { if (!attributes.Contains(a.Key, a.Value)) { return(false); } } return(true); }