示例#1
0
        public static Likeness <TSource, TDestination> WithInnerSpecificLikeness
        <TSource, TDestination, TSourceProperty, TDestinationProperty, TSourcePropertySubType, TDestinationPropertySubType>
        (
            this Likeness <TSource, TDestination> likeness,
            Expression <Func <TDestination, TDestinationProperty> > propertyPicker,
            Expression <Func <TSource, TSourceProperty> > sourcePropertyPicker,
            Func <Likeness <TSourcePropertySubType, TDestinationPropertySubType>, Likeness <TSourcePropertySubType, TDestinationPropertySubType> > likenessDefFunc
        )
            where TSourceProperty : class
            where TDestinationProperty : class
            where TSourcePropertySubType : class, TSourceProperty
            where TDestinationPropertySubType : class, TDestinationProperty
        {
            return(likeness.With(propertyPicker)
                   .EqualsWhen((s, d) =>
            {
                DiagnosticsWriterLocator.DiagnosticsWriter.WriteMessage(String.Format("Comparing inner properties using likeness. Source: {0} Destination: {1}.", sourcePropertyPicker, propertyPicker));

                var sourceVal = ExpressionUtils.GetValue(sourcePropertyPicker, s);
                var destVal = ExpressionUtils.GetValue(propertyPicker, d);


                return CompareUtils.CompareUsingLikeness(likenessDefFunc, sourceVal, destVal);
            }));
        }
示例#2
0
        public static bool CompareCollectionsUsingSpecificLikeness
        <TSourceCollectionItem, TDestinationCollectionItem, TSourceCollectionItemSubType, TDestinationCollectionItemSubType>
        (
            this IEnumerable <TSourceCollectionItem> sourceCollection,
            IEnumerable <TDestinationCollectionItem> destCollection,
            Func <Likeness <TSourceCollectionItemSubType, TDestinationCollectionItemSubType>, Likeness <TSourceCollectionItemSubType, TDestinationCollectionItemSubType> > likenessDefFunc = null

        )
            where TSourceCollectionItemSubType : class, TSourceCollectionItem
            where TDestinationCollectionItemSubType : class, TDestinationCollectionItem
            where TSourceCollectionItem : class
            where TDestinationCollectionItem : class
        {
            return(CompareUtils.CompareCollectionsUsingLikeness(likenessDefFunc, sourceCollection, destCollection));
        }
示例#3
0
        public static Likeness <TSource, TDestination> WithCollectionSequenceEquals <TSource, TDestination>
        (
            this Likeness <TSource, TDestination> likeness,
            Expression <Func <TDestination, IEnumerable> > propertyPicker,
            Expression <Func <TSource, IEnumerable> > sourcePropertyPicker
        )
        {
            return(likeness.With(propertyPicker)
                   .EqualsWhen((s, d) =>
            {
                DiagnosticsWriterLocator.DiagnosticsWriter.WriteMessage(String.Format("Comparing inner collections. Source: {0} Destination: {1}.", sourcePropertyPicker, propertyPicker));

                var sourceVal = ExpressionUtils.GetValue(sourcePropertyPicker, s);
                var destVal = ExpressionUtils.GetValue(propertyPicker, d);

                return CompareUtils.CheckIfCollectionEqual(sourceVal, destVal);
            }));
        }