Update Reference Sources to .NET Framework 4.6.1
[mono.git] / mcs / class / referencesource / System.Xml / System / Xml / Schema / XmlSchemaAnyAttribute.cs
1 //------------------------------------------------------------------------------
2 // <copyright file="XmlSchemaAnyAttribute.cs" company="Microsoft">
3 //     Copyright (c) Microsoft Corporation.  All rights reserved.
4 // </copyright> 
5 // <owner current="true" primary="true">[....]</owner>                                                               
6 //------------------------------------------------------------------------------
7
8 namespace System.Xml.Schema {
9
10     using System.Collections;
11     using System.ComponentModel;
12     using System.Xml.Serialization;
13
14     /// <include file='doc\XmlSchemaAnyAttribute.uex' path='docs/doc[@for="XmlSchemaAnyAttribute"]/*' />
15     /// <devdoc>
16     ///    <para>[To be supplied.]</para>
17     /// </devdoc>
18     public class XmlSchemaAnyAttribute : XmlSchemaAnnotated {
19         string ns;
20         XmlSchemaContentProcessing processContents = XmlSchemaContentProcessing.None;
21         NamespaceList namespaceList;
22         
23         /// <include file='doc\XmlSchemaAnyAttribute.uex' path='docs/doc[@for="XmlSchemaAnyAttribute.Namespaces"]/*' />
24         /// <devdoc>
25         ///    <para>[To be supplied.]</para>
26         /// </devdoc>
27         [XmlAttribute("namespace")]
28         public string Namespace {
29             get { return ns; }
30             set { ns = value; }
31         }
32         
33         /// <include file='doc\XmlSchemaAnyAttribute.uex' path='docs/doc[@for="XmlSchemaAnyAttribute.ProcessContents"]/*' />
34         /// <devdoc>
35         ///    <para>[To be supplied.]</para>
36         /// </devdoc>
37         [XmlAttribute("processContents"), DefaultValue(XmlSchemaContentProcessing.None)]
38         public XmlSchemaContentProcessing ProcessContents {
39             get { return processContents; }
40             set { processContents = value; }
41         }
42
43
44         [XmlIgnore]
45         internal NamespaceList NamespaceList {
46             get { return namespaceList; }
47         }
48
49         [XmlIgnore]
50         internal XmlSchemaContentProcessing ProcessContentsCorrect {
51             get { return processContents == XmlSchemaContentProcessing.None ? XmlSchemaContentProcessing.Strict : processContents; }
52         }
53
54         internal void BuildNamespaceList(string targetNamespace) {
55             if (ns != null) {
56                 namespaceList = new NamespaceList(ns, targetNamespace);
57             }
58             else {
59                 namespaceList = new NamespaceList();
60             }
61         }
62
63         internal void BuildNamespaceListV1Compat(string targetNamespace) {
64             if (ns != null) {
65                 namespaceList = new NamespaceListV1Compat(ns, targetNamespace);
66             }
67             else {
68                 namespaceList = new NamespaceList(); //This is only ##any, hence base class is sufficient
69             }
70         }
71
72         internal bool Allows(XmlQualifiedName qname) {
73             return namespaceList.Allows(qname.Namespace);
74         }
75
76         internal static bool IsSubset(XmlSchemaAnyAttribute sub, XmlSchemaAnyAttribute super) {
77             return NamespaceList.IsSubset(sub.NamespaceList, super.NamespaceList);
78         }
79
80         internal static XmlSchemaAnyAttribute Intersection(XmlSchemaAnyAttribute o1, XmlSchemaAnyAttribute o2, bool v1Compat) {
81             NamespaceList nsl = NamespaceList.Intersection(o1.NamespaceList, o2.NamespaceList, v1Compat);
82             if (nsl != null) {
83                 XmlSchemaAnyAttribute anyAttribute = new XmlSchemaAnyAttribute();
84                 anyAttribute.namespaceList = nsl;
85                 anyAttribute.ProcessContents = o1.ProcessContents;
86                 anyAttribute.Annotation = o1.Annotation;
87                 return anyAttribute;
88             }
89             else {
90                 // not expressible
91                 return null;
92             }
93         }
94
95         internal static XmlSchemaAnyAttribute Union(XmlSchemaAnyAttribute o1, XmlSchemaAnyAttribute o2, bool v1Compat) {
96             NamespaceList nsl = NamespaceList.Union(o1.NamespaceList, o2.NamespaceList, v1Compat);
97             if (nsl != null) {
98                 XmlSchemaAnyAttribute anyAttribute = new XmlSchemaAnyAttribute();
99                 anyAttribute.namespaceList = nsl;
100                 anyAttribute.processContents = o1.processContents;
101                 anyAttribute.Annotation = o1.Annotation;
102                 return anyAttribute;
103             }
104             else {
105                 // not expressible
106                 return null;
107             }
108         }
109     }
110 }