+2006-11-14 Atsushi Enomoto <atsushi@ximian.com>
+
+ * XmlSchemaValidatingReader.cs : dispatch validation events from
+ XmlReaderSettings. Turned out that outside System.Xml.dll
+ XmlReaderSettings.ValidationEventHandler is useless.
+
2006-10-27 Atsushi Enomoto <atsushi@ximian.com>
* XsdValidatingReader.cs : Fixed bug #79650. Enumeration facet was
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
v.Initialize ();
}
- public ValidationEventHandler ValidationEventHandler;
+ public event ValidationEventHandler ValidationEventHandler {
+ add { v.ValidationEventHandler += value; }
+ remove { v.ValidationEventHandler -= value; }
+ }
public XmlSchemaType ElementSchemaType {
get {
+2006-11-14 Atsushi Enomoto <atsushi@ximian.com>
+
+ * 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 <michael.meeks@novell.com>
* XmlReader.cs, XmlTextReader.cs, XmlTextReader2.cs:
validationType = org.validationType;
nameTable = org.nameTable;
xmlResolver = org.xmlResolver;
+ if (org.ValidationEventHandler != null)
+ ValidationEventHandler += org.ValidationEventHandler;
}
public event ValidationEventHandler ValidationEventHandler;
}
}
+ 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;
+2006-11-14 Atsushi Enomoto <atsushi@ximian.com>
+
+ * XmlReaderSettingsTests.cs : added validation event handler test
+ case.
+
2006-11-13 Atsushi Enomoto <atsushi@ximian.com>
* XmlReaderSettingsTests.cs : added custom resolver case for primary
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