本文整理汇总了C#中ValidationEventHandler类的典型用法代码示例。如果您正苦于以下问题:C# ValidationEventHandler类的具体用法?C# ValidationEventHandler怎么用?C# ValidationEventHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ValidationEventHandler类属于命名空间,在下文中一共展示了ValidationEventHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Compile
// 1. name and public must be present
// public and system must be anyURI
internal override int Compile(ValidationEventHandler h, XmlSchema schema)
{
// If this is already compiled this time, simply skip.
if (CompilationId == schema.CompilationId)
return 0;
if(Name == null)
error(h,"Required attribute name must be present");
else if(!XmlSchemaUtil.CheckNCName(this.name))
error(h,"attribute name must be NCName");
else
qualifiedName = new XmlQualifiedName(Name, AncestorSchema.TargetNamespace);
if(Public==null)
error(h,"public must be present");
else if(!XmlSchemaUtil.CheckAnyUri(Public))
error(h,"public must be anyURI");
if(system != null && !XmlSchemaUtil.CheckAnyUri(system))
error(h,"system must be present and of Type anyURI");
XmlSchemaUtil.CompileID(Id,this,schema.IDCollection,h);
return errorCount;
}
示例2: AddToTable
public static void AddToTable (XmlSchemaObjectTable table, XmlSchemaObject obj,
XmlQualifiedName qname, ValidationEventHandler h)
{
if (table.Contains (qname)) {
// FIXME: This logic unexpectedly allows
// one redefining item and two or more redefining items.
// FIXME: redefining item is not simple replacement,
// but much more complex stuff.
if (obj.isRedefineChild) { // take precedence.
if (obj.redefinedObject != null)
obj.error (h, String.Format ("Named item {0} was already contained in the schema object table.", qname));
else
obj.redefinedObject = table [qname];
table.Set (qname, obj);
}
else if (table [qname].isRedefineChild) {
if (table [qname].redefinedObject != null)
obj.error (h, String.Format ("Named item {0} was already contained in the schema object table.", qname));
else
table [qname].redefinedObject = obj;
return; // never add to the table.
}
else if (StrictMsCompliant) {
table.Set (qname, obj);
}
else
obj.error (h, String.Format ("Named item {0} was already contained in the schema object table. {1}",
qname, "Consider setting MONO_STRICT_MS_COMPLIANT to 'yes' to mimic MS implementation."));
}
else
table.Set (qname, obj);
}
示例3: Preprocessor
public Preprocessor(XmlNameTable nameTable, SchemaNames schemaNames, ValidationEventHandler eventHandler, XmlSchemaCompilationSettings compilationSettings)
: base(nameTable, schemaNames, eventHandler, compilationSettings)
{
_referenceNamespaces = new Hashtable();
_processedExternals = new Hashtable();
_lockList = new SortedList();
}
示例4: Validate
public static void Validate(
XmlTextReader treader,
ValidationEventHandler validationHandler
)
{
XmlReaderSettings validator = null;
try
{
validator = new XmlReaderSettings();
XmlSchema schema = GetSchema();
validator.Schemas.Add(schema);
validator.ValidationType = ValidationType.Schema;
if (validationHandler!=null)
validator.ValidationEventHandler += validationHandler;
else
validator.ValidationEventHandler += new ValidationEventHandler(ValidationEvent);
XmlReader objXmlReader = XmlReader.Create(treader, validator);
while( objXmlReader.Read() ) {}
}
catch( Exception ex )
{
Console.WriteLine(ex.ToString()) ;
throw ;
}
finally
{
if (validationHandler!=null)
validator.ValidationEventHandler -= validationHandler;
else
validator.ValidationEventHandler -= new ValidationEventHandler(ValidationEvent);
}
}
示例5: Read
public static WebReferenceOptions Read(XmlReader xmlReader, ValidationEventHandler validationEventHandler)
{
WebReferenceOptions options;
XmlValidatingReader reader = new XmlValidatingReader(xmlReader) {
ValidationType = ValidationType.Schema
};
if (validationEventHandler != null)
{
reader.ValidationEventHandler += validationEventHandler;
}
else
{
reader.ValidationEventHandler += new ValidationEventHandler(WebReferenceOptions.SchemaValidationHandler);
}
reader.Schemas.Add(Schema);
webReferenceOptionsSerializer serializer = new webReferenceOptionsSerializer();
try
{
options = (WebReferenceOptions) serializer.Deserialize(reader);
}
catch (Exception exception)
{
throw exception;
}
finally
{
reader.Close();
}
return options;
}
示例6: CheckValidity
public override bool CheckValidity(XmlSchemaSet schemas, ValidationEventHandler validationEventHandler)
{
XmlDocument source;
if (this.source.NodeType == XmlNodeType.Document)
{
source = (XmlDocument) this.source;
}
else
{
source = this.source.OwnerDocument;
if (schemas != null)
{
throw new ArgumentException(Res.GetString("XPathDocument_SchemaSetNotAllowed", (object[]) null));
}
}
if ((schemas == null) && (source != null))
{
schemas = source.Schemas;
}
if ((schemas == null) || (schemas.Count == 0))
{
throw new InvalidOperationException(Res.GetString("XmlDocument_NoSchemaInfo"));
}
DocumentSchemaValidator validator = new DocumentSchemaValidator(source, schemas, validationEventHandler) {
PsviAugmentation = false
};
return validator.Validate(this.source);
}
示例7: Validate
public Boolean Validate()
{
XmlTextReader txtreader = null;
try
{
txtreader = new XmlTextReader(fileName);
XmlDocument doc = new XmlDocument();
doc.Load(txtreader);
ValidationEventHandler eventHandler = new ValidationEventHandler(ValidationEventHandler);
doc.Validate(eventHandler);
}
catch (IOException e)
{
LogBookController.Instance.addLogLine("Error accessing chapter files. Probably doesn't exist. \n" + e, LogMessageCategories.Error);
return false;
}
catch (XmlException e)
{
LogBookController.Instance.addLogLine("Error inside chapters XML file, trying again.\n" + e, LogMessageCategories.Error);
return false;
}
finally
{
txtreader.Close();
}
return true;
}
示例8: Compile
internal override int Compile(ValidationEventHandler h, XmlSchema schema)
{
// If this is already compiled this time, simply skip.
if (CompilationId == schema.CompilationId)
return 0;
XmlSchemaUtil.CompileID(Id, this, schema.IDCollection, h);
CompileOccurence (h, schema);
if (Items.Count == 0)
this.warn (h, "Empty choice is unsatisfiable if minOccurs not equals to 0");
foreach(XmlSchemaObject obj in Items)
{
if(obj is XmlSchemaElement ||
obj is XmlSchemaGroupRef ||
obj is XmlSchemaChoice ||
obj is XmlSchemaSequence ||
obj is XmlSchemaAny)
{
errorCount += obj.Compile(h,schema);
}
else
error(h, "Invalid schema object was specified in the particles of the choice model group.");
}
this.CompilationId = schema.CompilationId;
return errorCount;
}
示例9: Read
/// <summary>
/// Reads an XML Schema from the supplied TextReader.
/// </summary>
/// <param name="reader">The TextReader containing the XML Schema to read.</param>
/// <param name="validationEventHandler">The validation event handler that receives information about the XML Schema syntax errors.</param>
/// <returns>The XmlSchema object representing the XML Schema.</returns>
public static new XmlSchema Read(TextReader reader, ValidationEventHandler validationEventHandler)
{
using (XmlReader xr = XmlReader.Create(reader, SafeXmlSchema.defaultSettings))
{
return XmlSchema.Read(xr, validationEventHandler);
}
}
示例10: LoadVenues
/// <summary>
/// Parses the xml file into a list of polling venues
/// </summary>
/// <param name="xDocument">The xml file</param>
/// <param name="notifier">Event subscriber if validation of the xml file fails</param>
/// <returns>A list of polling venues</returns>
private List<PollingVenue> LoadVenues(XDocument xDocument, ValidationEventHandler notifier)
{
if (!this.ValidateXmlFile(xDocument, notifier)){
var pollingVenuesElements = from n in xDocument.Descendants("PollingVenue") select n;
List<PollingVenue> pollingVenues = new List<PollingVenue>();
foreach (var xElement in pollingVenuesElements){
Address pollingVenueAddress = new Address{
Name = xElement.Element("Name").Value,
Street = xElement.Element("Street").Value,
City = xElement.Element("City").Value
};
Address municipalityAddress = new Address{
Name = xElement.Parent.Parent.Element("Name").Value,
Street = xElement.Parent.Parent.Element("Street").Value,
City = xElement.Parent.Parent.Element("City").Value
};
PollingVenue pollingVenue = new PollingVenue{
Persons = this.LoadPersons(xElement),
PollingVenueAddress = pollingVenueAddress,
MunicipalityAddress = municipalityAddress
};
pollingVenues.Add(pollingVenue);
}
return pollingVenues;
}
return null;
}
示例11: Compile
///<remarks>
/// 1. Content must be present and one of restriction or extention
///</remarks>
internal override int Compile(ValidationEventHandler h, XmlSchema schema)
{
// If this is already compiled this time, simply skip.
if (CompilationId == schema.CompilationId)
return 0;
if(Content == null)
{
error(h, "Content must be present in a simpleContent");
}
else
{
if(Content is XmlSchemaSimpleContentRestriction)
{
XmlSchemaSimpleContentRestriction xscr = (XmlSchemaSimpleContentRestriction) Content;
errorCount += xscr.Compile(h, schema);
}
else if(Content is XmlSchemaSimpleContentExtension)
{
XmlSchemaSimpleContentExtension xsce = (XmlSchemaSimpleContentExtension) Content;
errorCount += xsce.Compile(h, schema);
}
else
error(h,"simpleContent can't have any value other than restriction or extention");
}
XmlSchemaUtil.CompileID(Id,this, schema.IDCollection,h);
this.CompilationId = schema.CompilationId;
return errorCount;
}
示例12: ValidategbXML_601
/// <summary>
/// Validate gbxml file against the 6.01 schema XSD
/// </summary>
private void ValidategbXML_601()
{
XmlDocument xml = new XmlDocument();
xml.Load(@"data/TestgbXML.xml");
xml.Schemas.Add(null, @"data/GreenBuildingXML_Ver6.01.xsd");
ValidationEventHandler eventHandler = new ValidationEventHandler(ValidationEventHandler);
xml.Validate(eventHandler);
}
示例13: BaseProcessor
public BaseProcessor(XmlNameTable nameTable, System.Xml.Schema.SchemaNames schemaNames, ValidationEventHandler eventHandler, XmlSchemaCompilationSettings compilationSettings)
{
this.nameTable = nameTable;
this.schemaNames = schemaNames;
this.eventHandler = eventHandler;
this.compilationSettings = compilationSettings;
this.NsXml = nameTable.Add("http://www.w3.org/XML/1998/namespace");
}
示例14: this
: this(nameTable, schemaNames, eventHandler, new XmlSchemaCompilationSettings()) {} //Use the default for XmlSchemaCollection
public BaseProcessor(XmlNameTable nameTable, SchemaNames schemaNames, ValidationEventHandler eventHandler, XmlSchemaCompilationSettings compilationSettings) {
Debug.Assert(nameTable != null);
this.nameTable = nameTable;
this.schemaNames = schemaNames;
this.eventHandler = eventHandler;
this.compilationSettings = compilationSettings;
NsXml = nameTable.Add(XmlReservedNs.NsXml);
}
示例15: XmlSchemaTypeGenerator
/// <summary>
/// Initializes the type generator
/// </summary>
/// <param name="useXmlSerializerImporter">if set to <c>true</c> [use XML serializer importer].</param>
/// <param name="targetNamespace">The target namespace.</param>
public XmlSchemaTypeGenerator(bool useXmlSerializerImporter, string targetNamespace)
{
Guard.ArgumentNotNull(targetNamespace, "targetNamespace");
this.validationEventHandler = new ValidationEventHandler(OnSchemasValidation);
this.useXmlSerializerImporter = useXmlSerializerImporter;
this.targetNamespace = targetNamespace;
}