当前位置: 首页>>代码示例>>C#>>正文


C# ValidationEventHandler类代码示例

本文整理汇总了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;
		}
开发者ID:nobled,项目名称:mono,代码行数:27,代码来源:XmlSchemaNotation.cs

示例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);
		}
开发者ID:carrie901,项目名称:mono,代码行数:32,代码来源:XmlSchemaUtil.cs

示例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();
 }
开发者ID:Corillian,项目名称:corefx,代码行数:7,代码来源:Preprocessor.cs

示例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);
            }
        }
开发者ID:Gutek,项目名称:MovingScrewdriver,代码行数:35,代码来源:BlogMLResource.cs

示例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;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:30,代码来源:WebReferenceOptions.cs

示例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);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:28,代码来源:DocumentXPathNavigator.cs

示例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;
        }
开发者ID:NeoBoy,项目名称:MiniCoder,代码行数:31,代码来源:XmlValidator.cs

示例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;
		}
开发者ID:nobled,项目名称:mono,代码行数:28,代码来源:XmlSchemaChoice.cs

示例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);
     }
 }
开发者ID:Pravinmprajapati,项目名称:ews-managed-api,代码行数:13,代码来源:SafeXmlSchema.cs

示例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;
        }
开发者ID:dirtylion,项目名称:smalltuba,代码行数:39,代码来源:FileLoader.cs

示例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;
		}
开发者ID:nobled,项目名称:mono,代码行数:33,代码来源:XmlSchemaSimpleContent.cs

示例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);
 }
开发者ID:Carmelsoft,项目名称:GenericgbXMLValidator_601,代码行数:11,代码来源:TestForm.cs

示例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");
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:BaseProcessor.cs

示例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);
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:10,代码来源:BaseProcessor.cs

示例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;
		}
开发者ID:Phidiax,项目名称:open-wssf-2015,代码行数:13,代码来源:XmlSchemaTypeGenerator.cs


注:本文中的ValidationEventHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。