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

XmlSchemaParticle.cs « System.Xml.Schema « System.XML « class « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 119c335b3c0204314c11062c1d2c6bec270961aa (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
// Author: Dwivedi, Ajay kumar
//            Adwiv@Yahoo.com
using System;
using System.Xml.Serialization;

namespace System.Xml.Schema
{
	/// <summary>
	/// Summary description for XmlSchemaParticle.
	/// </summary>
	public abstract class XmlSchemaParticle : XmlSchemaAnnotated
	{
		decimal minOccurs, maxOccurs;
		string  minstr, maxstr;

		protected XmlSchemaParticle()
		{
			minOccurs = decimal.One;
			maxOccurs = decimal.One;
		}

		#region Attributes

		[System.Xml.Serialization.XmlAttribute("minOccurs")]
		public string MinOccursString
		{
			get{ return minstr; }
			set
			{
				decimal val = decimal.Parse(value);
				if(val >= 0 && (val == Decimal.Truncate(val)))
				{
					minOccurs = val;
					minstr	 = val.ToString();
				}
				else
				{
					throw new XmlSchemaException
						("MinOccursString must be a non-negative number",null); 					
				}
			}
		}

		[System.Xml.Serialization.XmlAttribute("maxOccurs")]
		public string MaxOccursString
		{
			get{ return maxstr; }
			set
			{
				if(value == "unbounded")
				{
					maxstr = value;
					maxOccurs = decimal.MaxValue;
				}
				else
				{
					decimal val = decimal.Parse(value);
					if(val >= 0 && (val == Decimal.Truncate(val)))
					{
						maxOccurs = val;
						maxstr = val.ToString();
					}
					else
					{
						throw new XmlSchemaException
							("MaxOccurs must be a non-negative integer",null);
					}
				}
			}
		}

		#endregion

		#region XmlIgnore

		[XmlIgnore]
		public decimal MinOccurs
		{
			get{ return  minOccurs; }
			set
			{
				MinOccursString = value.ToString();
			}
		}

		[XmlIgnore]
		public decimal MaxOccurs 
		{
			get{ return  maxOccurs; } 
			set
			{
				MaxOccursString = value.ToString();
			}
		}

		#endregion
	}
}