Author: atsushi
Date: 2006-11-14 02:28:29 -0500 (Tue, 14 Nov 2006)
New Revision: 67814

Modified:
   trunk/mcs/class/System.XML/Mono.Xml.Schema/ChangeLog
   trunk/mcs/class/System.XML/Mono.Xml.Schema/XmlSchemaValidatingReader.cs
   trunk/mcs/class/System.XML/System.Xml/ChangeLog
   trunk/mcs/class/System.XML/System.Xml/XmlReaderSettings.cs
   trunk/mcs/class/System.XML/Test/System.Xml/ChangeLog
   trunk/mcs/class/System.XML/Test/System.Xml/XmlReaderSettingsTests.cs
Log:
2006-11-14  Atsushi Enomoto <[EMAIL PROTECTED]>

        * XmlReaderSettings.cs : in copy constructor, copy (dispatch)
          validation event as well. Add OnValidationError() to be invoked
          by other internal stuff to raise the validation event.

        * XmlSchemaValidatingReader.cs : dispatch validation events from
          XmlReaderSettings. Turned out that outside System.Xml.dll
          XmlReaderSettings.ValidationEventHandler is useless.

        * XmlReaderSettingsTests.cs : added validation event handler test
          case.



Modified: trunk/mcs/class/System.XML/Mono.Xml.Schema/ChangeLog
===================================================================
--- trunk/mcs/class/System.XML/Mono.Xml.Schema/ChangeLog        2006-11-14 
05:04:04 UTC (rev 67813)
+++ trunk/mcs/class/System.XML/Mono.Xml.Schema/ChangeLog        2006-11-14 
07:28:29 UTC (rev 67814)
@@ -1,3 +1,9 @@
+2006-11-14  Atsushi Enomoto <[EMAIL PROTECTED]>
+
+       * XmlSchemaValidatingReader.cs : dispatch validation events from
+         XmlReaderSettings. Turned out that outside System.Xml.dll
+         XmlReaderSettings.ValidationEventHandler is useless.
+
 2006-10-27  Atsushi Enomoto <[EMAIL PROTECTED]>
 
        * XsdValidatingReader.cs : Fixed bug #79650. Enumeration facet was

Modified: 
trunk/mcs/class/System.XML/Mono.Xml.Schema/XmlSchemaValidatingReader.cs
===================================================================
--- trunk/mcs/class/System.XML/Mono.Xml.Schema/XmlSchemaValidatingReader.cs     
2006-11-14 05:04:04 UTC (rev 67813)
+++ trunk/mcs/class/System.XML/Mono.Xml.Schema/XmlSchemaValidatingReader.cs     
2006-11-14 07:28:29 UTC (rev 67814)
@@ -135,6 +135,9 @@
                        v.LineInfoProvider = this;
                        v.ValidationEventSender = reader;
 #if !NON_MONO
+                       ValidationEventHandler += delegate (object o, 
ValidationEventArgs e) {
+                               settings.OnValidationError (o, e);
+                       };
                        if (settings != null && settings.Schemas != null)
                                v.XmlResolver = settings.Schemas.XmlResolver;
                        else
@@ -145,7 +148,10 @@
                        v.Initialize ();
                }
 
-               public ValidationEventHandler ValidationEventHandler;
+               public event ValidationEventHandler ValidationEventHandler {
+                       add { v.ValidationEventHandler += value; }
+                       remove { v.ValidationEventHandler -= value; }
+               }
 
                public XmlSchemaType ElementSchemaType {
                        get {

Modified: trunk/mcs/class/System.XML/System.Xml/ChangeLog
===================================================================
--- trunk/mcs/class/System.XML/System.Xml/ChangeLog     2006-11-14 05:04:04 UTC 
(rev 67813)
+++ trunk/mcs/class/System.XML/System.Xml/ChangeLog     2006-11-14 07:28:29 UTC 
(rev 67814)
@@ -1,3 +1,9 @@
+2006-11-14  Atsushi Enomoto <[EMAIL PROTECTED]>
+
+       * XmlReaderSettings.cs : in copy constructor, copy (dispatch)
+         validation event as well. Add OnValidationError() to be invoked
+         by other internal stuff to raise the validation event.
+
 2006-11-13  Michael Meeks  <[EMAIL PROTECTED]>
 
        * XmlReader.cs, XmlTextReader.cs, XmlTextReader2.cs:

Modified: trunk/mcs/class/System.XML/System.Xml/XmlReaderSettings.cs
===================================================================
--- trunk/mcs/class/System.XML/System.Xml/XmlReaderSettings.cs  2006-11-14 
05:04:04 UTC (rev 67813)
+++ trunk/mcs/class/System.XML/System.Xml/XmlReaderSettings.cs  2006-11-14 
07:28:29 UTC (rev 67814)
@@ -79,6 +79,8 @@
                        validationType = org.validationType;
                        nameTable = org.nameTable;
                        xmlResolver = org.xmlResolver;
+                       if (org.ValidationEventHandler != null)
+                               ValidationEventHandler += 
org.ValidationEventHandler;
                }
 
                public event ValidationEventHandler ValidationEventHandler;
@@ -175,6 +177,14 @@
                        }
                }
 
+               internal void OnValidationError (object o, ValidationEventArgs 
e)
+               {
+                       if (ValidationEventHandler != null)
+                               ValidationEventHandler (o, e);
+                       else if (e.Severity == XmlSeverityType.Error)
+                               throw e.Exception;
+               }
+
                internal void SetSchemas (XmlSchemaSet schemas)
                {
                        this.schemas = schemas;

Modified: trunk/mcs/class/System.XML/Test/System.Xml/ChangeLog
===================================================================
--- trunk/mcs/class/System.XML/Test/System.Xml/ChangeLog        2006-11-14 
05:04:04 UTC (rev 67813)
+++ trunk/mcs/class/System.XML/Test/System.Xml/ChangeLog        2006-11-14 
07:28:29 UTC (rev 67814)
@@ -1,3 +1,8 @@
+2006-11-14  Atsushi Enomoto <[EMAIL PROTECTED]>
+
+       * XmlReaderSettingsTests.cs : added validation event handler test
+         case.
+
 2006-11-13  Atsushi Enomoto <[EMAIL PROTECTED]>
 
        * XmlReaderSettingsTests.cs : added custom resolver case for primary

Modified: trunk/mcs/class/System.XML/Test/System.Xml/XmlReaderSettingsTests.cs
===================================================================
--- trunk/mcs/class/System.XML/Test/System.Xml/XmlReaderSettingsTests.cs        
2006-11-14 05:04:04 UTC (rev 67813)
+++ trunk/mcs/class/System.XML/Test/System.Xml/XmlReaderSettingsTests.cs        
2006-11-14 07:28:29 UTC (rev 67814)
@@ -342,6 +342,22 @@
                                        xr.Read ();
                        }
                }
+
+               [Test]
+               [ExpectedException (typeof (ApplicationException))]
+               public void ValidationEventHandler ()
+               {
+                       XmlReaderSettings settings = new XmlReaderSettings ();
+                       settings.Schemas.Add (new XmlSchema ());
+                       settings.ValidationType = ValidationType.Schema;
+                       settings.ValidationEventHandler += delegate (object o, 
ValidationEventArgs e) {
+                               throw new ApplicationException ();
+                       };
+                       XmlReader r = XmlReader.Create (
+                               new StringReader ("<root/>"), settings);
+                       while (!r.EOF)
+                               r.Read ();
+               }
        }
 }
 #endif

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to