문제

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?

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top