1 //------------------------------------------------------------------------------
2 // <copyright file="SchemaDeclBase.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
5 // <owner current="true" primary="true">[....]</owner>
6 //------------------------------------------------------------------------------
8 namespace System.Xml.Schema {
10 using System.Collections.Generic;
11 using System.Diagnostics;
13 internal abstract class SchemaDeclBase {
22 protected XmlQualifiedName name = XmlQualifiedName.Empty;
23 protected string prefix;
24 protected bool isDeclaredInExternal = false;
25 protected Use presence; // the presence, such as fixed, implied, etc
28 protected XmlSchemaType schemaType;
29 protected XmlSchemaDatatype datatype;
31 protected string defaultValueRaw; // default value in its original form
32 protected object defaultValueTyped;
34 protected long maxLength; // dt:maxLength
35 protected long minLength; // dt:minLength
37 protected List<string> values; // array of values for enumerated and notation types
40 protected SchemaDeclBase(XmlQualifiedName name, string prefix) {
50 protected SchemaDeclBase() {
54 internal XmlQualifiedName Name {
59 internal string Prefix {
60 get { return(prefix == null) ? string.Empty : prefix;}
61 set { prefix = value;}
64 internal bool IsDeclaredInExternal {
65 get { return isDeclaredInExternal;}
66 set { isDeclaredInExternal = value;}
69 internal Use Presence {
70 get { return presence; }
71 set { presence = value; }
75 internal long MaxLength {
76 get { return maxLength;}
77 set { maxLength = value;}
80 internal long MinLength {
81 get { return minLength;}
82 set { minLength = value;}
85 internal XmlSchemaType SchemaType {
86 get { return schemaType;}
87 set { schemaType = value;}
90 internal XmlSchemaDatatype Datatype {
91 get { return datatype;}
92 set { datatype = value;}
95 internal void AddValue(string value) {
97 values = new List<string>();
102 internal List<string> Values {
103 get { return values; }
104 set { values = value; }
107 internal string DefaultValueRaw {
108 get { return(defaultValueRaw != null) ? defaultValueRaw : string.Empty;}
109 set { defaultValueRaw = value;}
112 internal object DefaultValueTyped {
113 get { return defaultValueTyped;}
114 set { defaultValueTyped = value;}
117 internal bool CheckEnumeration(object pVal) {
118 return (datatype.TokenizedType != XmlTokenizedType.NOTATION && datatype.TokenizedType != XmlTokenizedType.ENUMERATION) || values.Contains(pVal.ToString());
121 internal bool CheckValue(Object pVal) {
122 return (presence != Use.Fixed && presence != Use.RequiredFixed) || (defaultValueTyped != null && datatype.IsEqual(pVal, defaultValueTyped));