System.Runtime.Serialization.XsdDataContractImporter.CanImport C# (CSharp) Метод

CanImport() приватный Метод

private CanImport ( XmlSchemaSet schemas, XmlSchemaComplexType type ) : bool
schemas System.Xml.Schema.XmlSchemaSet
type System.Xml.Schema.XmlSchemaComplexType
Результат bool
		bool CanImport (XmlSchemaSet schemas, XmlSchemaComplexType type)
		{
			if (type == null || type.QualifiedName.Namespace == XmlSchema.Namespace) // xs:anyType -> not supported.
				return false;

			if (type.ContentModel is XmlSchemaSimpleContent) // simple content derivation is not supported.
				return false;
			if (type.ContentModel != null && type.ContentModel.Content != null) {
				var xscce = type.ContentModel.Content as XmlSchemaComplexContentExtension;
				if (xscce == null) // complex DBR is not supported.
					return false;
				// check base type
				if (xscce.BaseTypeName != qname_anytype && !CanImport (schemas, xscce.BaseTypeName))
					return false;
			}

			return true;
		}

Same methods

XsdDataContractImporter::CanImport ( XmlSchemaSet schemas ) : bool
XsdDataContractImporter::CanImport ( XmlSchemaSet schemas, ICollection typeNames ) : bool
XsdDataContractImporter::CanImport ( XmlSchemaSet schemas, XmlQualifiedName typeName ) : bool
XsdDataContractImporter::CanImport ( XmlSchemaSet schemas, XmlSchemaElement element ) : bool

Usage Example

Пример #1
0
		void DoCanImport (bool result, params string [] schemaFiles)
		{
			var ccu = new CodeCompileUnit ();
			var xdi = new XsdDataContractImporter (ccu);
			var xss = new XmlSchemaSet ();
			foreach (var schemaFile in schemaFiles)
				xss.Add (null, schemaFile);
			Assert.AreEqual (result, xdi.CanImport (xss));
		}
All Usage Examples Of System.Runtime.Serialization.XsdDataContractImporter::CanImport