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
reference
IEnumerable<T>A common baseline from which both
theirs
andmine
were modified.theirs
IEnumerable<T>The foreign list with changes that shall be merged in.
mine
IEnumerable<T>The local list that shall be updated with foreign changes.
added
Action<T>Called for every element that should be added to
mine
.removed
Action<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
reference
IEnumerable<T>A common baseline from which both
theirs
andmine
were modified.theirs
IEnumerable<T>The foreign list with changes that shall be merged in.
mine
IEnumerable<T>The local list that shall be updated with foreign changes.
added
ICollection<TAdded>All elements that should be added to
mine
are added to this list.removed
ICollection<TRemoved>All elements that should be removed from
mine
are added to this list.
Type Parameters
T
TAdded
TRemoved
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
theirs
IEnumerable<T>The foreign list with changes that shall be merged in.
mine
IEnumerable<T>The local list that shall be updated with foreign changes.
added
Action<T>Called for every element that should be added to
mine
.removed
Action<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
theirs
IEnumerable<T>The foreign list with changes that shall be merged in.
mine
IEnumerable<T>The local list that shall be updated with foreign changes.
added
ICollection<TAdded>All elements that should be added to
mine
are added to this list.removed
ICollection<TRemoved>All elements that should be removed from
mine
are added to this list.
Type Parameters
T
TAdded
TRemoved
Remarks
theirs
and mine
should use an internal hashmap for System.Collections.Generic.ICollection<T>.Contains(T) for better performance.