I have these code. With so many repetitive parts, how should I encapsulate them into a parameter?
IEnumerable<List<GeminiFileStruct>> delGfl = null;
if (m_comparemode == GeminiCompareMode.HASH)
{
delGfl =
from i in delGflChecked
where File.Exists((i.fullPath))
group i by i.hash into grp
where grp.Count() > 1
select grp.ToList();
}
else if (m_comparemode == GeminiCompareMode.ExtAndSize)
{
delGfl =
from i in delGflChecked
where File.Exists((i.fullPath))
group i by new { i.size, i.extName } into grp
where grp.Count() > 1
select grp.ToList();
}
else
{
delGfl =
from i in delGflChecked
where File.Exists((i.fullPath))
group i by i.size into grp
where grp.Count() > 1
select grp.ToList();
}
[code duplicated][1] [1]: https://i.stack.imgur.com/cSSwq.png