The Labs \ Source Viewer \ SSCLI \ System.Xml.Serialization \ SoapAttributeFlags

  1. //------------------------------------------------------------------------------
  2. // <copyright file="SoapAttributes.cs" company="Microsoft">
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. // </copyright>
  14. // <owner current="true" primary="true">ElenaK</owner>
  15. //------------------------------------------------------------------------------
  16. namespace System.Xml.Serialization
  17. {
  18.     using System;
  19.     using System.Reflection;
  20.     using System.Collections;
  21.     using System.ComponentModel;
  22.    
  23.     internal enum SoapAttributeFlags
  24.     {
  25.         Enum = 1,
  26.         Type = 2,
  27.         Element = 4,
  28.         Attribute = 8
  29.     }
  30.    
  31.     /// <include file='doc\SoapAttributes.uex' path='docs/doc[@for="SoapAttributes"]/*' />
  32.     /// <devdoc>
  33.     /// <para>[To be supplied.]</para>
  34.     /// </devdoc>
  35.     public class SoapAttributes
  36.     {
  37.         bool soapIgnore;
  38.         SoapTypeAttribute soapType;
  39.         SoapElementAttribute soapElement;
  40.         SoapAttributeAttribute soapAttribute;
  41.         SoapEnumAttribute soapEnum;
  42.         object soapDefaultValue = null;
  43.        
  44.         /// <include file='doc\SoapAttributes.uex' path='docs/doc[@for="SoapAttributes.SoapAttributes"]/*' />
  45.         /// <devdoc>
  46.         /// <para>[To be supplied.]</para>
  47.         /// </devdoc>
  48.         public SoapAttributes()
  49.         {
  50.         }
  51.        
  52.         /// <include file='doc\SoapAttributes.uex' path='docs/doc[@for="SoapAttributes.SoapAttributes1"]/*' />
  53.         /// <devdoc>
  54.         /// <para>[To be supplied.]</para>
  55.         /// </devdoc>
  56.         public SoapAttributes(ICustomAttributeProvider provider)
  57.         {
  58.             object[] attrs = provider.GetCustomAttributes(false);
  59.             for (int i = 0; i < attrs.Length; i++) {
  60.                 if (attrs[i] is SoapIgnoreAttribute || attrs[i] is ObsoleteAttribute) {
  61.                     this.soapIgnore = true;
  62.                     break;
  63.                 }
  64.                 else if (attrs[i] is SoapElementAttribute) {
  65.                     this.soapElement = (SoapElementAttribute)attrs[i];
  66.                 }
  67.                 else if (attrs[i] is SoapAttributeAttribute) {
  68.                     this.soapAttribute = (SoapAttributeAttribute)attrs[i];
  69.                 }
  70.                 else if (attrs[i] is SoapTypeAttribute) {
  71.                     this.soapType = (SoapTypeAttribute)attrs[i];
  72.                 }
  73.                 else if (attrs[i] is SoapEnumAttribute) {
  74.                     this.soapEnum = (SoapEnumAttribute)attrs[i];
  75.                 }
  76.                 else if (attrs[i] is DefaultValueAttribute) {
  77.                     this.soapDefaultValue = ((DefaultValueAttribute)attrs[i]).Value;
  78.                 }
  79.             }
  80.             if (soapIgnore) {
  81.                 this.soapElement = null;
  82.                 this.soapAttribute = null;
  83.                 this.soapType = null;
  84.                 this.soapEnum = null;
  85.                 this.soapDefaultValue = null;
  86.             }
  87.         }
  88.        
  89.         internal SoapAttributeFlags SoapFlags {
  90.             get {
  91.                 SoapAttributeFlags flags = 0;
  92.                 if (soapElement != null)
  93.                     flags |= SoapAttributeFlags.Element;
  94.                 if (soapAttribute != null)
  95.                     flags |= SoapAttributeFlags.Attribute;
  96.                 if (soapEnum != null)
  97.                     flags |= SoapAttributeFlags.Enum;
  98.                 if (soapType != null)
  99.                     flags |= SoapAttributeFlags.Type;
  100.                 return flags;
  101.             }
  102.         }
  103.        
  104.         /// <include file='doc\SoapAttributes.uex' path='docs/doc[@for="SoapAttributes.SoapType"]/*' />
  105.         /// <devdoc>
  106.         /// <para>[To be supplied.]</para>
  107.         /// </devdoc>
  108.         public SoapTypeAttribute SoapType {
  109.             get { return soapType; }
  110.             set { soapType = value; }
  111.         }
  112.        
  113.         /// <include file='doc\SoapAttributes.uex' path='docs/doc[@for="SoapAttributes.SoapEnum"]/*' />
  114.         /// <devdoc>
  115.         /// <para>[To be supplied.]</para>
  116.         /// </devdoc>
  117.         public SoapEnumAttribute SoapEnum {
  118.             get { return soapEnum; }
  119.             set { soapEnum = value; }
  120.         }
  121.        
  122.         /// <include file='doc\SoapAttributes.uex' path='docs/doc[@for="SoapAttributes.SoapIgnore"]/*' />
  123.         /// <devdoc>
  124.         /// <para>[To be supplied.]</para>
  125.         /// </devdoc>
  126.         public bool SoapIgnore {
  127.             get { return soapIgnore; }
  128.             set { soapIgnore = value; }
  129.         }
  130.        
  131.         /// <include file='doc\SoapAttributes.uex' path='docs/doc[@for="SoapAttributes.SoapElement"]/*' />
  132.         /// <devdoc>
  133.         /// <para>[To be supplied.]</para>
  134.         /// </devdoc>
  135.         public SoapElementAttribute SoapElement {
  136.             get { return soapElement; }
  137.             set { soapElement = value; }
  138.         }
  139.        
  140.         /// <include file='doc\SoapAttributes.uex' path='docs/doc[@for="SoapAttributes.SoapAttribute"]/*' />
  141.         /// <devdoc>
  142.         /// <para>[To be supplied.]</para>
  143.         /// </devdoc>
  144.         public SoapAttributeAttribute SoapAttribute {
  145.             get { return soapAttribute; }
  146.             set { soapAttribute = value; }
  147.         }
  148.        
  149.         /// <include file='doc\SoapAttributes.uex' path='docs/doc[@for="SoapAttributes.SoapDefaultValue"]/*' />
  150.         /// <devdoc>
  151.         /// <para>[To be supplied.]</para>
  152.         /// </devdoc>
  153.         public object SoapDefaultValue {
  154.             get { return soapDefaultValue; }
  155.             set { soapDefaultValue = value; }
  156.         }
  157.     }
  158. }

Developer Fusion