System.XML: added null arguments validation for targetType and namespaceResolver...
[mono.git] / mcs / class / System.XML / System.Xml.Schema / XmlSchemaObject.cs
index a0c942686f258ca3f98d5c5b6107cb15444044dc..d3de335fb9b13dd16de26bed2092d9691e99d7bc 100644 (file)
@@ -45,22 +45,29 @@ namespace System.Xml.Schema
                internal ArrayList unhandledAttributeList ;
                internal bool isCompiled = false;
                internal int errorCount = 0;
-               internal Guid CompilationId;
+               internal Guid compilation_id;
                internal Guid ValidationId;
                internal bool isRedefineChild;
                internal bool isRedefinedComponent;
                internal XmlSchemaObject redefinedObject;
 
-#if NET_2_0
                private XmlSchemaObject parent;
-#endif
 
 
                protected XmlSchemaObject()
                {
                        namespaces = new XmlSerializerNamespaces();
                        unhandledAttributeList = null;
-                       CompilationId = Guid.Empty;
+                       compilation_id = Guid.Empty;
+               }
+               
+               internal Guid CompilationId {
+                       get { return compilation_id; }
+                       set {
+                               if (value.Equals (Guid.Empty))
+                                       throw new ArgumentException ("value must not be empty");
+                               compilation_id = value;
+                       }
                }
 
                [XmlIgnore]
@@ -84,11 +91,29 @@ namespace System.Xml.Schema
 
 #if NET_2_0
                [XmlIgnore]
-               public XmlSchemaObject Parent {
+               public
+#else
+               internal
+#endif
+               XmlSchemaObject Parent {
                        get { return parent; }
                        set { parent = value; }
                }
-#endif
+
+               internal XmlSchema AncestorSchema {
+                       get {
+                               
+                               for (XmlSchemaObject o = Parent; o != null; o = o.Parent)
+                                       if (o is XmlSchema)
+                                               return (XmlSchema) o;
+                               throw new Exception (String.Format ("INTERNAL ERROR: Parent object is not set properly : {0} ({1},{2})", SourceUri, LineNumber, LinePosition));
+                       }
+               }
+
+               internal virtual void SetParent (XmlSchemaObject parent)
+               {
+                       Parent = parent;
+               }
 
                // Undocumented Property
                [XmlNamespaceDeclarations]