I am working on an 3rd party implementation to our site. The API that I am calling on code returns an unique value pair.
ValueType: //code, percent, money
Value: //depending on ValueType can be string, int, or object { currency: string, amount: decimal }
I am trying to put my head on it but can't seem to find a proper way to parse it on a C# object other that having enum
and object
.
public class ReturnType
{
public EnumValueType ValueType { get; set; }
public object Value { get; set; }
}
public enum EnumValueType
{
MONEY,
PERCENT,
CODE
}
This makes it harder to access Value
. I am looking for another solution.
Any suggestions for POCO class to parse it in a proper way would be appreciated.