Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
XmlSchemaParticle.cs
Go to the documentation of this file.
2
3namespace System.Xml.Schema;
4
5public abstract class XmlSchemaParticle : XmlSchemaAnnotated
6{
7 [Flags]
8 private enum Occurs
9 {
10 None = 0,
11 Min = 1,
12 Max = 2
13 }
14
15 private sealed class EmptyParticle : XmlSchemaParticle
16 {
17 internal override bool IsEmpty => true;
18 }
19
20 private decimal _minOccurs = 1m;
21
22 private decimal _maxOccurs = 1m;
23
24 private Occurs _flags;
25
26 internal static readonly XmlSchemaParticle Empty = new EmptyParticle();
27
28 [XmlAttribute("minOccurs")]
29 public string? MinOccursString
30 {
31 get
32 {
33 if ((_flags & Occurs.Min) != 0)
34 {
36 }
37 return null;
38 }
39 set
40 {
41 if (value == null)
42 {
43 _minOccurs = 1m;
44 _flags &= ~Occurs.Min;
45 return;
46 }
48 if (_minOccurs < 0m)
49 {
50 throw new XmlSchemaException(System.SR.Sch_MinOccursInvalidXsd, string.Empty);
51 }
52 _flags |= Occurs.Min;
53 }
54 }
55
56 [XmlAttribute("maxOccurs")]
57 public string? MaxOccursString
58 {
59 get
60 {
61 if ((_flags & Occurs.Max) != 0)
62 {
63 if (!(_maxOccurs == decimal.MaxValue))
64 {
66 }
67 return "unbounded";
68 }
69 return null;
70 }
71 set
72 {
73 if (value == null)
74 {
75 _maxOccurs = 1m;
76 _flags &= ~Occurs.Max;
77 return;
78 }
79 if (value == "unbounded")
80 {
81 _maxOccurs = decimal.MaxValue;
82 }
83 else
84 {
86 if (_maxOccurs < 0m)
87 {
88 throw new XmlSchemaException(System.SR.Sch_MaxOccursInvalidXsd, string.Empty);
89 }
90 if (_maxOccurs == 0m && (_flags & Occurs.Min) == 0)
91 {
92 _minOccurs = default(decimal);
93 }
94 }
95 _flags |= Occurs.Max;
96 }
97 }
98
99 [XmlIgnore]
100 public decimal MinOccurs
101 {
102 get
103 {
104 return _minOccurs;
105 }
106 set
107 {
108 if (value < 0m || value != decimal.Truncate(value))
109 {
110 throw new XmlSchemaException(System.SR.Sch_MinOccursInvalidXsd, string.Empty);
111 }
113 _flags |= Occurs.Min;
114 }
115 }
116
117 [XmlIgnore]
118 public decimal MaxOccurs
119 {
120 get
121 {
122 return _maxOccurs;
123 }
124 set
125 {
126 if (value < 0m || value != decimal.Truncate(value))
127 {
128 throw new XmlSchemaException(System.SR.Sch_MaxOccursInvalidXsd, string.Empty);
129 }
131 if (_maxOccurs == 0m && (_flags & Occurs.Min) == 0)
132 {
133 _minOccurs = default(decimal);
134 }
135 _flags |= Occurs.Max;
136 }
137 }
138
139 internal virtual bool IsEmpty => _maxOccurs == 0m;
140
141 internal bool IsMultipleOccurrence => _maxOccurs > 1m;
142
143 internal virtual string NameString => string.Empty;
144
146 {
148 {
149 return xmlSchemaElement.QualifiedName;
150 }
152 {
153 string @namespace = xmlSchemaAny.Namespace;
154 @namespace = ((@namespace == null) ? string.Empty : @namespace.Trim());
155 return new XmlQualifiedName("*", (@namespace.Length == 0) ? "##any" : @namespace);
156 }
157 return XmlQualifiedName.Empty;
158 }
159}
static string Sch_MaxOccursInvalidXsd
Definition SR.cs:752
static string Sch_MinOccursInvalidXsd
Definition SR.cs:754
Definition SR.cs:7
static string ToString(bool value)
static decimal ToInteger(string s)
static readonly XmlQualifiedName Empty