Exemple #1
0
        /// <summary>
        ///     Creates an equality comparer that compare the equality of two objects based on the equality of each field or
        ///     property tagged by the specified attributes.
        /// </summary>
        /// <typeparam name="T">The type of the objects to compare.</typeparam>
        /// <param name="attributeTypes"></param>
        /// <returns>The memberwise equality comparer.</returns>
        public static IEqualityComparer <T> ByTaggedMembers <T>(params Type[] attributeTypes)
            where T : class
        {
            InnerGuard.RequiresValidAttributeTypes(attributeTypes);

            return(ByMembers <T>(member => member.HasAnyAttribute(attributeTypes)));
        }
Exemple #2
0
        /// <summary>
        ///     Creates an equality comparer that compare the equality of two objects based on the equality of each property tagged
        ///     by the specified attributes.
        /// </summary>
        /// <typeparam name="T">The type of the objects to compare.</typeparam>
        /// <param name="attributeTypes"></param>
        /// <returns>The propertywise equality comparer.</returns>
        public static IEqualityComparer <T> ByTaggedProperties <T>(params Type[] attributeTypes)
            where T : class
        {
            InnerGuard.RequiresValidAttributeTypes(attributeTypes);

            return(ByProperties <T>(property => property.HasAnyAttribute(attributeTypes)));
        }
Exemple #3
0
        /// <summary>
        ///     Creates an equality comparer that compare the equality of two objects based on the equality of each field tagged by
        ///     the specified attributes.
        /// </summary>
        /// <typeparam name="T">The type of the objects to compare.</typeparam>
        /// <param name="attributeTypes"></param>
        /// <returns>The fieldwise equality comparer.</returns>
        public static IEqualityComparer <T> ByTaggedFields <T>(params Type[] attributeTypes)
            where T : class
        {
            InnerGuard.RequiresValidAttributeTypes(attributeTypes);

            return(ByFields <T>(field => field.HasAnyAttribute(attributeTypes)));
        }