title: Flags with web services
body: <p>I have a flag attribute enumeration that is behind a web service as follows:</p>
  
  <pre><code>[Serializable,Flags]
  public enum AccessLevels
  {
      None = 0,
      Read = 1,
      Write = 2,
      Full = Read | Write
  }
  </code></pre>
  
  <p>My problem is the consumer of my web service does not have the original constant values of the enum. The resulting proxy class client side has something that amounts to this:</p>
  
  <pre><code>{
     None = 1,
     Read = 2,
     Write = 4,
     Full = 8
  }
  </code></pre>
  
  <p>And thus when the consumer is checking for "Read" access this will be false even when "testItem" is "Full"</p>
  
  <pre><code>((testItem &amp; Svc.Read) == Svc.Read)
  </code></pre>
  
  <p>How can I properly provide flags over a web service?</p>
  
  <p>EDIT:</p>
  
  <p>According to <a href="http://ikriv.com:8765/en/prog/info/dotnet/WebServices_and_Enums.html" rel="nofollow noreferrer">this</a> article it may not be possible to do what I am looking to do. Ivan Krivyakov states</p>
  
  <blockquote>
    <p>Imperfect Transparency of Enums</p>
    
    <p>It turns out that enums are not as
    transparent as we'd like them to be.
    There are three sticky issues:</p>
    
    <ol>
    <li>If server-side code declares an enum and assigns specific numeric
    values to its members, these values
    will not be visible to the client.</li>
    <li>If server-side code declares a [Flags] enum with "compound" mask
    values (as in White = Red|Green|Blue),
    it is not properly reflected on the
    client side.</li>
    <li>If server or client transmits an "illegal" value which is outside of
    the scope of the enum, it causes an
    exception in XML de-serializer on the
    other side.</li>
    </ol>
  </blockquote>
  
  <p>So I wonder if this is just a limitation and is not possible.</p>