public void Apply(CollectionWorkSpace <T> workspace) { var property = typeof(T).GetProperty(PropertyName); var toRemove = workspace.List.FirstOrDefault(t => property?.GetValue(t, null)?.Equals(ExpectValue) ?? false); if (toRemove is not null) { workspace.List.Remove(toRemove); } }
public void Apply(CollectionWorkSpace <T> workspace) { var property = typeof(T).GetProperty(SearchPropertyName); var patchProperty = typeof(T).GetProperty(PatchPropertyName); var toPatch = workspace.List.FirstOrDefault(t => property?.GetValue(t, null)?.Equals(ExpectValue) ?? false); if (toPatch is not null) { patchProperty?.SetValue(toPatch, NewValue); } }
public void Apply(CollectionWorkSpace <string> workspace) { foreach (var diffItem in Diff) { switch (diffItem.Status) { case DiffStatus.Inserted: workspace.List.Insert(diffItem.LineNumber, diffItem.NewLine); break; case DiffStatus.Deleted: workspace.List.RemoveAt(diffItem.LineNumber); break; } } }
public void Apply(CollectionWorkSpace <T> workspace) { workspace.List.Add(Item); }