src/Misc/EFTools/EntityDesignEntityDesigner/GeneratedCode/SerializationHelper.cs
/// <summary>
/// Attempts to return a validating XML reader
/// </summary>
/// <returns>If the Core domain model schema and all of the schema referenced in the file can be resolved,
/// then a validating reader is returned. Otherwise, the supplied reader is returned.
/// The serialization context will contain warning messages for all schema that could not be resolved.</returns>
Attempts to return a validating XML reader
Attempts to return a validating XML reader
protected virtual global::System.Xml.XmlReader TryCreateValidatingReader(DslModeling::ISchemaResolver schemaResolver, global::System.Xml.XmlReader reader, DslModeling::SerializationContext serializationContext)
		{
			if (schemaResolver == null)
			{
				return reader;
			}
			global::System.Xml.Schema.XmlSchemaSet schemaSet = new global::System.Xml.Schema.XmlSchemaSet(reader.NameTable);
			bool success = true;
			success = success && ResolveSchema(DslModeling::CoreDomainModelSerializationBehavior.DomainModelXmlNamespace, schemaSet, schemaResolver, reader, serializationContext);
			System.Collections.ObjectModel.ReadOnlyCollection<string> namespaces = DslModeling::SerializationUtilities.GetNamespacesFromCurrentNode(reader);
			foreach (string ns in namespaces)
			{
				if (string.CompareOrdinal(DslModeling::CoreDomainModelSerializationBehavior.DomainModelXmlNamespace, ns) == 0)
				{
					continue;
				}
				success = success & ResolveSchema(ns, schemaSet, schemaResolver, reader, serializationContext);
			}
			if (success && schemaSet.Count > 0)
			{
				global::System.Xml.XmlReaderSettings readerSettings = reader.Settings.Clone();
				readerSettings.ConformanceLevel = global::System.Xml.ConformanceLevel.Auto;
				readerSettings.ValidationType = global::System.Xml.ValidationType.Schema;
				readerSettings.Schemas = schemaSet;
				MicrosoftDataEntityDesignSerializationBehaviorSchemaValidationCallback validationCallback = new MicrosoftDataEntityDesignSerializationBehaviorSchemaValidationCallback(serializationContext);
				readerSettings.ValidationEventHandler += new global::System.Xml.Schema.ValidationEventHandler(validationCallback.Handler);
				global::System.Xml.XmlReader validatingReader = global::System.Xml.XmlReader.Create(reader, readerSettings);
				validationCallback.Reader = validatingReader;
				return validatingReader;
			}
			return reader;
		}
protected virtual global :: System . Xml . XmlReader TryCreateValidatingReader ( DslModeling :: ISchemaResolver schemaResolver , global :: System . Xml . XmlReader reader , DslModeling :: SerializationContext serializationContext ) { if ( schemaResolver == null ) { return reader ; } global :: System . Xml . Schema . XmlSchemaSet schemaSet = new global :: System . Xml . Schema . XmlSchemaSet ( reader . NameTable ) ; bool success = true ; success = success && ResolveSchema ( DslModeling :: CoreDomainModelSerializationBehavior . DomainModelXmlNamespace , schemaSet , schemaResolver , reader , serializationContext ) ; System . Collections . ObjectModel . ReadOnlyCollection < string > namespaces = DslModeling :: SerializationUtilities . GetNamespacesFromCurrentNode ( reader ) ; foreach ( string ns in namespaces ) { if ( string . CompareOrdinal ( DslModeling :: CoreDomainModelSerializationBehavior . DomainModelXmlNamespace , ns ) == 0 ) { continue ; } success = success & ResolveSchema ( ns , schemaSet , schemaResolver , reader , serializationContext ) ; } if ( success && schemaSet . Count > 0 ) { global :: System . Xml . XmlReaderSettings readerSettings = reader . Settings . Clone ( ) ; readerSettings . ConformanceLevel = global :: System . Xml . ConformanceLevel . Auto ; readerSettings . ValidationType = global :: System . Xml . ValidationType . Schema ; readerSettings . Schemas = schemaSet ; MicrosoftDataEntityDesignSerializationBehaviorSchemaValidationCallback validationCallback = new MicrosoftDataEntityDesignSerializationBehaviorSchemaValidationCallback ( serializationContext ) ; readerSettings . ValidationEventHandler += new global :: System . Xml . Schema . ValidationEventHandler ( validationCallback . Handler ) ; global :: System . Xml . XmlReader validatingReader = global :: System . Xml . XmlReader . Create ( reader , readerSettings ) ; validationCallback . Reader = validatingReader ; return validatingReader ; } return reader ; }
Attempts to return a validating XML reader
Attempts to return a validating XML reader
// Can't do anything without a schema resolver // Flags whether all schema were resolved successfully // Must be able to reference the Core namespace. // Resolve other schema namespaces // Skip the namespaces that have already been resolved // Note - using & so that ResolveSchema is always called // Wrap the given reader as a validating reader and carry out the normal deserialization.
If the Core domain model schema and all of the schema referenced in the file can be resolved,
then a validating reader is returned. Otherwise, the supplied reader is returned.
The serialization context will contain warning messages for all schema that could not be resolved.
If the Core domain model schema and all of the schema referenced in the file can be resolved then a validating reader is returned . Otherwise the supplied reader is returned . The serialization context will contain warning messages for all schema that could not be resolved .
schemaResolver
DslModeling::ISchemaResolver
reader
global::System.Xml.XmlReader
serializationContext
DslModeling::SerializationContext