Pergunta

Given the following enum which is used only as output in a wcf service:

[DataContract] 
public enum Role
{
   [EnumMember]
   Undefined = 0,

   [EnumMember]
   Admin,

   [EnumMember] 
   Supervisor,

   [EnumMember]
   User
}

...is it true that I could change the integer values without breaking compatibility with existing clients? Like this:

[DataContract] 
public enum Role
{
   [EnumMember]
   Undefined = 0,

   [EnumMember]
   Admin = 10,

   [EnumMember] 
   Supervisor = 20,

   [EnumMember]
   User = 30
}

AFAIK enumerations are transferred through wcf (soap, to be more exact) as strings. Is there something which I miss here?

Foi útil?

Solução

WCF does preserve the numerical values in a data contract when using a WCF client and using DataContract and the DataContractSerializer.

If this is not the case, only the member name will be transferred.

Source: http://msdn.microsoft.com/en-us/library/aa347875.aspx

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top