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)); }
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; } }