Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have been looking for hours now and i have no idea how to solve my problem. I am writing a Service Stack API and I need whoever is going to consume it to pass in valid values in only.

I have a Client node and under there is firstname, lastname, address, state, etc.

Now for the state field it needs to be enumerable is some way so they can only choose for example (NT, NSW, WA, SA)

So they will go something like objClient.State = State.NT;

BTW this is in C# asp.net with mono framework.

Now what i have tried is to do a private static readonly string BLABLABLA; but that didn't work, Its not getting serialized. All My DTO's have [DataContract] and [DataMember] tags at the appropriate places. I Tried doing [Flags] above the enum that i tried but no luck.

So i am stuck at the moment. I don't want the consumer of the api to just pass in a string value. can anyone help me get unstuck with some suggestions how to do this?

share|improve this question
    
dont know if this will work tho? msdn.microsoft.com/en-us/library/… –  Shane Van Wyk May 5 '13 at 9:16
1  

1 Answer 1

up vote 1 down vote accepted

I solved this using:

[DataContract]
public enum Color
{
    [DataMember]
    Red,
    [DataMember]
    Blue,
    [DataMember]
    Green,
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.