Is there any possibility of refactoring this code?
In class A:
public List<Item> GetItems() {
var result = new List<Item>();
foreach(var item in repo.GetItems1()) {
var x = repo.GetOtherItems1(item.Id, "param1", param2); // this part is different
if (x.Value > 5)
result.Add(x);
}
return result;
}
In class B:
public List<Item> GetItems() {
var result = new List<Item>();
foreach(var item in repo.GetItems2()) {
var x = repo.GetOtherItems2(param1, param2, item.Id); // this part is different
if (x.Value > 5)
result.Add(x);
}
return result;
}
I tried to use template method, but due to other params in GetOtherItemsX(...)
, is it now possible?