I'm having a hard time deserializing a HashSet of enums. Currently the values from the XML are not being deserialized into the c# object.
I have an xml file that has this:
<MyHashSetOfEnums xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a:MyEnum>Red</a:MyEnum>
<a:MyEnum>Green</a:MyEnum>
<a:MyEnum>Blue</a:MyEnum>
</MyHashSetOfEnums>
And the c# class I'm trying to deserialize them into looks something like this:
[DataContract]
public class MyClass
{
[DataMember]
public HashSet<MyEnum> MyHashSetOfEnums { get; private set; }
}
Enum looks like this:
public enum MyEnum
{
Red,
Green,
Blue
}
I have working code that deserializes a single enum and another that deserializes a HashSet of strings/ints. Both of these use different XML namespaces to deserialize correctly. But now I need to combine the two ideas and am unable to get something working. Is this possible? Or am I shooting for something unreachable here?
PS: I am not using Newtonsoft and cannot upgrade our serialization utilities to use Newtonsoft