0

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.

darcane
  • 473
  • 3
  • 14

1 Answers1

0

Maybe you can make 3 methods and use overloading (same method name, 3 different signatures), 1 that takes lets say string/enum and string, 1 that takes string/enum and int, and for the last one, string/enum and for the object make a new class and define currency: string, amount: decimal properties and make it accept that. I dont know if I helped, but there you go...

Costa
  • 1,794
  • 1
  • 12
  • 21