Class Merge
Provides utility methods for merging System.Collections.Generic.ICollection<T>s.
public static class Merge
- Inheritance
-
objectMerge
Methods
ThreeWay<T>(IEnumerable<T>, IEnumerable<T>, IEnumerable<T>, Action<T>, Action<T>)
Performs a 3-way merge on a set of collections. Changes between reference and theirs as they apply to mine are emitted using callback delegates.
public static void ThreeWay<T>(IEnumerable<T> reference, IEnumerable<T> theirs, IEnumerable<T> mine, Action<T> added, Action<T> removed) where T : class, IMergeable<T>
Parameters
referenceIEnumerable<T>A common baseline from which both
theirsandminewere modified.theirsIEnumerable<T>The foreign list with changes that shall be merged in.
mineIEnumerable<T>The local list that shall be updated with foreign changes.
addedAction<T>Called for every element that should be added to
mine.removedAction<T>Called for every element that should be removed from
mine.
Type Parameters
T
Remarks
Modified elements are handled by calling removed for the old state and added for the new state.
ThreeWay<T, TAdded, TRemoved>(IEnumerable<T>, IEnumerable<T>, IEnumerable<T>, ICollection<TAdded>, ICollection<TRemoved>)
Performs a 3-way merge on a set of collections. Changes between reference and theirs as they apply to mine are recorded using differential lists.
public static void ThreeWay<T, TAdded, TRemoved>(IEnumerable<T> reference, IEnumerable<T> theirs, IEnumerable<T> mine, ICollection<TAdded> added, ICollection<TRemoved> removed) where T : class, IMergeable<T>, TAdded, TRemoved
Parameters
referenceIEnumerable<T>A common baseline from which both
theirsandminewere modified.theirsIEnumerable<T>The foreign list with changes that shall be merged in.
mineIEnumerable<T>The local list that shall be updated with foreign changes.
addedICollection<TAdded>All elements that should be added to
mineare added to this list.removedICollection<TRemoved>All elements that should be removed from
mineare added to this list.
Type Parameters
TTAddedTRemoved
Remarks
Modified elements are handled by adding to removed for the old state and to added for the new state.
TwoWay<T>(IEnumerable<T>, IEnumerable<T>, Action<T>, Action<T>)
Performs a 2-way merge on two collections. Changes required to theirs to reflect mine are emitted using callback delegates.
public static void TwoWay<T>(IEnumerable<T> theirs, IEnumerable<T> mine, Action<T> added, Action<T> removed)
Parameters
theirsIEnumerable<T>The foreign list with changes that shall be merged in.
mineIEnumerable<T>The local list that shall be updated with foreign changes.
addedAction<T>Called for every element that should be added to
mine.removedAction<T>Called for every element that should be removed from
mine.
Type Parameters
T
Remarks
theirs and mine should use an internal hashmap for System.Collections.Generic.ICollection<T>.Contains(T) for better performance.
TwoWay<T, TAdded, TRemoved>(IEnumerable<T>, IEnumerable<T>, ICollection<TAdded>, ICollection<TRemoved>)
Performs a 2-way merge on two collections. Changes required to theirs to reflect mine are recorded using differential lists.
public static void TwoWay<T, TAdded, TRemoved>(IEnumerable<T> theirs, IEnumerable<T> mine, ICollection<TAdded> added, ICollection<TRemoved> removed) where T : class, TAdded, TRemoved
Parameters
theirsIEnumerable<T>The foreign list with changes that shall be merged in.
mineIEnumerable<T>The local list that shall be updated with foreign changes.
addedICollection<TAdded>All elements that should be added to
mineare added to this list.removedICollection<TRemoved>All elements that should be removed from
mineare added to this list.
Type Parameters
TTAddedTRemoved
Remarks
theirs and mine should use an internal hashmap for System.Collections.Generic.ICollection<T>.Contains(T) for better performance.