Flags with web services

后端 未结 4 1250
灰色年华
灰色年华 2021-01-05 14:08

I have a flag attribute enumeration that is behind a web service as follows:

[Serializable,Flags]
public enum AccessLevels
{
    None = 0,
    Read = 1,
             


        
4条回答
  •  粉色の甜心
    2021-01-05 14:20

    I had a similar problem and got round it by adding another web service to return the currect flag values first.

    Those then became the values I used in the compare.

    Might not be the cleanest solution but it works.

    Edit:

    My original answer suggested that the values are passed across as a separate web service rather than within an enum.

    However, poking around, it appears that an enumeration of 0,1,2 being mapped to 1,2,4 across a web service (even that the [Flags] attribute is set) is a common problem.

    The solution suggested by a number of people is to modify the original enumeration definition and start from 1 rather than 0.

提交回复
热议问题