Implement IEquatable in WinRT solution?

281 views Asked by At

So I have a bit of an issue. I'll see how well I can explain it.

I have a class that is shared between my windows phone foreground app and the background as a link (they both use the same file) this is because data is serialized from this class and passed back in forth so it needs to be exactly the same.

In the foreground process I want to use IEquatable to be able to override GetHash and Equals so when I call ObservableCollection.Remove on an ItemModel it doesn't remove based on reference and I can have it manually compare properties as I am removing an item selected from another list (ie. 2 identical items each have their own spot in memory).

I've tested and it works fine, but I cannot implement IEquatable in a Windows Runtime interface (I don't quite get this anyway, but okay) "Error 10 Type 'Project.ViewModels.ItemModel ' implements interface 'System.IEquatable', which is not a Windows Runtime interface. All interfaces that are implemented by exported types must be Windows Runtime interfaces. "

So IEquatable is allowed in the foreground process, but not the background but because they are using the linked file. You might ask, why not just make a duplicate of this class in the background project and not implement IEquatable? Well because I started running into issues serializing and deserializing data when the two classes weren't defined exactly alike..

  public class ItemModel: INotifyPropertyChanged, IEquatable<ItemModel>
0

There are 0 answers