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