Import() public method

public Import ( XmlSchemaSet schemas, XmlSchemaElement element ) : XmlQualifiedName
schemas System.Xml.Schema.XmlSchemaSet
element System.Xml.Schema.XmlSchemaElement
return System.Xml.XmlQualifiedName
		void IWsdlImportExtension.ImportContract (WsdlImporter importer,
			WsdlContractConversionContext context)
		{
			if (!enabled)
				return;

			if (importer == null)
				throw new ArgumentNullException ("importer");
			if (context == null)
				throw new ArgumentNullException ("context");
			if (this.importer != null || this.context != null)
				throw new SystemException ("INTERNAL ERROR: unexpected recursion of ImportContract method call");

			dc_importer = new XsdDataContractImporter ();
			schema_set_in_use = new XmlSchemaSet ();
			schema_set_in_use.Add (importer.XmlSchemas);
			foreach (WSDL wsdl in importer.WsdlDocuments)
				foreach (XmlSchema xs in wsdl.Types.Schemas)
					schema_set_in_use.Add (xs);
			dc_importer.Import (schema_set_in_use);

			this.importer = importer;
			this.context = context;
			try {
				DoImportContract ();
			} finally {
				this.importer = null;
				this.context = null;
			}
		}
		CodeCompileUnit DoImport (bool xmlType, params string [] schemaFiles)
		{
			var ccu = new CodeCompileUnit ();
			var xdi = new XsdDataContractImporter (ccu);
			if (xmlType)
				xdi.Options = new ImportOptions () { ImportXmlType = true };
			var xss = new XmlSchemaSet ();
			foreach (var schemaFile in schemaFiles)
				xss.Add (null, schemaFile);
			xdi.Import (xss);

			return ccu;
		}
		public void ImportGivesAppropriateNamespaces ()
		{
			var ccu = new CodeCompileUnit ();
			var xdi = new XsdDataContractImporter (ccu);
			var xss = new XmlSchemaSet ();
			xss.Add (null, "Test/Resources/Schemas/schema1.xsd");
			xss.Add (null, "Test/Resources/Schemas/schema2.xsd");
			xss.Add (null, "Test/Resources/Schemas/schema3.xsd");
			xdi.Import (xss);
			var sw = new StringWriter ();
			bool t = false, te = false;
			foreach (CodeNamespace cns in ccu.Namespaces) {
				if (cns.Name == "tempuri.org")
					t = true;
				else if (cns.Name == "tempuri.org.ext")
					te = true;
				Assert.AreEqual ("GetSearchDataResponse", cns.Types [0].Name, "#1." + cns.Name);
			}
			Assert.IsTrue (t, "t");
			Assert.IsTrue (t, "te");
		}
		public void ImportSkipArrayOfPrimitives ()
		{
			var ccu = new CodeCompileUnit ();
			var xdi = new XsdDataContractImporter (ccu);
			var xss = new XmlSchemaSet ();
			xss.Add (null, "Test/Resources/Schemas/schema1.xsd");
			xss.Add (null, "Test/Resources/Schemas/schema2.xsd");
			xdi.Import (xss);
			var sw = new StringWriter ();
			new CSharpCodeProvider ().GenerateCodeFromCompileUnit (ccu, sw, null);
			Assert.IsTrue (sw.ToString ().IndexOf ("ArrayOfint") < 0, "#1");
		}
		CodeCompileUnit DoImport (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);
			xdi.Import (xss);

			return ccu;
		}
        private CodeCompileUnit GenerateTypesWithDataContractImporter(XmlSchemaSet schemas)
		{
			XsdDataContractImporter importer = new XsdDataContractImporter();
			importer.Options = CreateImportOptions(false);

			schemas.ValidationEventHandler += this.validationEventHandler;

			try
			{				
				importer.Import(schemas);
				return importer.CodeCompileUnit;
			}
			catch (InvalidDataContractException dataContractException)
			{
				// double check since CanImport may trigger a "false" positive
				// after adding serialization and types schemas
				importer.CanImport(schemas);
				if (!importer.CanImport(schemas))
				{
					throw new InvalidSerializerException(dataContractException.Message);
				}
				throw;
			}
			catch (ArgumentException argumentException)
			{
				throw new InvalidOperationException(argumentException.Message, argumentException.InnerException);
			}
			finally
			{
				schemas.ValidationEventHandler -= this.validationEventHandler;
			}
		}