Welcome to mirror list, hosted at ThFree Co, Russian Federation.

XmlSchemaInfo.cs « Schema « Xml « System « System.Xml « referencesource « class « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 81d503a135413332ace8065bc68adcb019c466c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
//------------------------------------------------------------------------------
// <copyright file="XmlSchemaInfo.cs" company="Microsoft">
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// </copyright>
// <owner current="true" primary="true">[....]</owner> 
//------------------------------------------------------------------------------

using System.Xml;
using System.Collections;

namespace System.Xml.Schema {

    /// <include file='doc\IXmlSchemaInfo.uex' path='docs/doc[@for="IXmlSchemaInfo"]/*' />
    public class XmlSchemaInfo : IXmlSchemaInfo {
        bool isDefault;
        bool isNil;
        XmlSchemaElement schemaElement;
        XmlSchemaAttribute schemaAttribute;
        XmlSchemaType schemaType;
        XmlSchemaSimpleType memberType;
        XmlSchemaValidity validity;
        XmlSchemaContentType contentType;
    
        public XmlSchemaInfo() {
            Clear();
        }

        internal XmlSchemaInfo(XmlSchemaValidity validity) : this() {
            this.validity = validity;
        }

        public XmlSchemaValidity Validity {
            get {
                return validity;                
            }
            set {
                validity = value;
            }
        }

        public bool IsDefault { 
            get {
                return isDefault;
            }
            set {
                isDefault = value;
            }
        }
        
        public bool IsNil { 
            get {
                return isNil;
            }
            set {
                isNil = value;
            }
        }

        public XmlSchemaSimpleType MemberType { 
            get {
                return memberType;
            }
            set {
                memberType = value;
            }
        }

        public XmlSchemaType SchemaType {
            get {
                return schemaType;
            }
            set {
                schemaType = value;
                if (schemaType != null) { //Member type will not change its content type
                    contentType = schemaType.SchemaContentType;
                }
                else {
                    contentType = XmlSchemaContentType.Empty;
                }
            }
        }

        public XmlSchemaElement SchemaElement {
            get {
                return schemaElement;
            }
            set {
                schemaElement = value;
                if (value != null) { //Setting non-null SchemaElement means SchemaAttribute should be null
                    schemaAttribute = null;
                }
            }       
        }

        public XmlSchemaAttribute SchemaAttribute {
            get {
                return schemaAttribute;
            }
            set {
                schemaAttribute = value;
                if (value != null) { //Setting non-null SchemaAttribute means SchemaElement should be null
                    schemaElement = null;
                }
            }   
        }

        public XmlSchemaContentType ContentType {
            get {
                return contentType;
            }
            set {
                contentType = value;
            }
        }

        internal XmlSchemaType XmlType {
            get {
                if (memberType != null) {
                    return memberType;
                }
                return schemaType;
            }
        }

        internal bool HasDefaultValue {
            get {
                return schemaElement != null && schemaElement.ElementDecl.DefaultValueTyped != null;
            }
        }

        internal bool IsUnionType {
            get {
                if (schemaType == null || schemaType.Datatype == null) {
                    return false;
                }
                return schemaType.Datatype.Variety == XmlSchemaDatatypeVariety.Union;
            }
        }

        internal void Clear() {
            isNil = false;
            isDefault = false;
            schemaType = null;
            schemaElement = null;
            schemaAttribute = null;
            memberType = null;
            validity = XmlSchemaValidity.NotKnown;
            contentType = XmlSchemaContentType.Empty;
        }
    }
}