Okay, so I have the following classes/interfaces
FilterFileViewModel
, CategoryViewModel
, IFilterViewModel
, ICategoryViewModel
.
Inheritance is set up as follows:
IFilterViewMode : IEqualityComparer<IFilterViewModel>
ICategoryViewModel : IFilterViewModel
FilterViewModel : ViewModel, IFilterViewModel
CategoryViewModel :FilterViewModel, ICategoryViewModel
And I have implemented IEqualityComparer
in the abstract class FilterViewModel
.
Now, I have an IEnumerable<ICategoryViewModel>
, but if I call "Contains" on it, it doesn't seem to use the Equals
method I have implemented at FilterViewModel
.
I can see that it's most likely because ICategoryViewModel
doesn't have the Equals
method... so the only solution I can think of is to have a collection of IEnumerable<CategoryViewModel>
instead, but this isn't ideal.
Can anyone think of a better way to structure this?