private static void PerformMerge <TSubject, TApplyTo>(ICollection <IPatternApplier <TSubject, TApplyTo> > destination, IPatternApplier <TSubject, TApplyTo> applier) { var applierType = applier.GetType(); if (IsDelegatedApplier(applierType) || !destination.Any(a => a.GetType() == applierType)) { destination.Add(applier); } }
private static void PerformUnionWith <TSubject, TApplyTo>(ICollection <IPatternApplier <TSubject, TApplyTo> > destination, IPatternApplier <TSubject, TApplyTo> applier) { var applierType = applier.GetType(); var existingAppliers = destination.Where(a => a.GetType().Name == applierType.Name && !IsDelegatedApplier(applierType)).ToList(); if (existingAppliers.Count > 0) { foreach (var existingApplier in existingAppliers) { destination.Remove(existingApplier); } } destination.Add(applier); }