IDiffAlgorithm <TType> IDiffAlgorithmRules.GetAlgorithm <TType>() { this.ValidateType <TType>(); if (Class <TType> .EnumerableParam == null) { throw new Exception("Cannot compare non-collection type with OrderedCollectionDiff"); } Property idProperty = GeneralRulesHelper.GetIdProperty(this.MergerImplementation, Class <TType> .EnumerableParam); if (idProperty == null) { return((IDiffAlgorithm <TType>)Activator.CreateInstance( typeof(UnorderedCollectionDiff <,>).MakeGenericType( typeof(TType), Class <TType> .EnumerableParam ), this.MergerImplementation )); } else { return((IDiffAlgorithm <TType>)Activator.CreateInstance( typeof(UnorderedCollectionWithIdDiff <, ,>).MakeGenericType( typeof(TType), idProperty.Type, Class <TType> .EnumerableParam ), this.MergerImplementation )); } }
public OrderedCollectionDiff(MergerImplementation mergerImplementation) { this.aMergerImplementation = mergerImplementation; this.aIsTheSame = null; this.aIDProperty = GeneralRulesHelper <TItemType> .GetIdProperty(mergerImplementation); }
public ApplyUnorderedCollectionWithIdPatch(MergerImplementation mergerImplementation) { this.aMergerImplementation = mergerImplementation; this.aIdProperty = GeneralRulesHelper <TItemType> .GetIdProperty(mergerImplementation); this.aApplyItemDiff = null; }
public MergeUnorderedCollectionDiffs(MergerImplementation mergerImplementation) { this.aMergerImplementation = mergerImplementation; this.aIdProperty = GeneralRulesHelper <TItemType> .GetIdProperty(mergerImplementation); this.aComparer = EqualityComparer <TIdType> .Default; }
private Expression MightBeChanged(ParameterExpression ret, Property property, ParameterExpression @base, ParameterExpression changed) { Property id = GeneralRulesHelper.GetIdProperty(this.aMergerImplementation, property.Type); MemberExpression baseProperty = Expression.Property(@base, property.ReflectionPropertyInfo); MemberExpression changedProperty = Expression.Property(changed, property.ReflectionPropertyInfo); Expression finalize; if (id != null) { MemberExpression baseId = Expression.Property(baseProperty, id.ReflectionPropertyInfo); MemberExpression changedId = Expression.Property(changedProperty, id.ReflectionPropertyInfo); finalize = Expression.IfThenElse( Expression.Equal(baseId, changedId), this.NewDiffChanged(ret, property, @base, changed), this.NewDiffReplaced(ret, property, @base, changed) ); } else { finalize = this.NewDiffChanged(ret, property, @base, changed); } if (!property.ReflectionPropertyInfo.PropertyType.IsValueType) { finalize = Expression.IfThenElse( Expression.OrElse( Expression.ReferenceEqual( baseProperty, Expression.Constant(null) ), Expression.ReferenceEqual( changedProperty, Expression.Constant(null) ) ), Expression.IfThenElse( Expression.ReferenceNotEqual( baseProperty, changedProperty ), this.NewDiffReplaced(ret, property, @base, changed), this.NewDiffUnchanged(ret, property, @base) ), finalize ); } return(finalize); }
public ValueDiff(MergerImplementation mergerImplementation) { this.aMergerImplementation = mergerImplementation; this.aIDProperty = GeneralRulesHelper <TType> .GetIdProperty(mergerImplementation); }
public UnorderedCollectionWithIdDiff(MergerImplementation mergerImplementation) { this.aMergerImplementation = mergerImplementation; this.aIdProperty = GeneralRulesHelper <TItemType> .GetIdProperty(mergerImplementation); }