System.Runtime.Serialization.XsdDataContractImporter.CanImport C# (CSharp) Method

CanImport() public method

public CanImport ( XmlSchemaSet schemas, XmlQualifiedName typeName ) : bool
schemas System.Xml.Schema.XmlSchemaSet
typeName System.Xml.XmlQualifiedName
return bool
		public bool CanImport (XmlSchemaSet schemas, XmlQualifiedName typeName)
		{
			if (schemas == null)
				throw new ArgumentNullException ("schemas");
			if (typeName == null)
				throw new ArgumentNullException ("typeName");

			if (!schemas.IsCompiled)
				schemas.Compile ();

			if (!schemas.GlobalTypes.Contains (typeName))
				throw new InvalidDataContractException (String.Format ("Type {0} is not found in the schemas", typeName));

			return CanImport (schemas, schemas.GlobalTypes [typeName] as XmlSchemaComplexType);
		}

Same methods

XsdDataContractImporter::CanImport ( XmlSchemaSet schemas ) : bool
XsdDataContractImporter::CanImport ( XmlSchemaSet schemas, ICollection typeNames ) : bool
XsdDataContractImporter::CanImport ( XmlSchemaSet schemas, XmlSchemaComplexType type ) : bool
XsdDataContractImporter::CanImport ( XmlSchemaSet schemas, XmlSchemaElement element ) : bool

Usage Example

		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