Flags with web services

后端 未结 4 1209
灰色年华
灰色年华 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:27

    I have done extensive research on this and found that it is not possible to serialize enumeration constants through a web service. Note that to accomplish your goal you don't need the enumerations None or Full. These two enumerations can be implied with read / write combination:

    You could assume full access if your AccessLevels = Read | Write and none if your AccessLevels = 0 [nothing]

    Your enumerations would look like this:

    [Serializable,Flags]
    public enum AccessLevels
    {
        Read = 1,
        Write = 2
    }
    

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题