public void GenerateSchemas ()
{
Assembly assembly = null;
try
{
assembly = Assembly.LoadFrom ((string) assemblies [0]);
}
catch (Exception ex)
{
Error (errLoadAssembly, ex.Message);
}
Type[] types;
if (lookupTypes.Count > 0)
{
types = new Type [lookupTypes.Count];
for (int n=0; n<lookupTypes.Count; n++)
{
Type t = assembly.GetType ((string)lookupTypes[n]);
if (t == null) Error (typeNotFound, (string)lookupTypes[n]);
types[n] = t;
}
}
else
types = assembly.GetExportedTypes ();
XmlReflectionImporter ri = new XmlReflectionImporter ();
XmlSchemas schemas = new XmlSchemas ();
XmlSchemaExporter sx = new XmlSchemaExporter (schemas);
foreach (Type type in types)
{
XmlTypeMapping tm = ri.ImportTypeMapping (type);
sx.ExportTypeMapping (tm);
}
if (schemas.Count == 1)
{
string fileName = Path.Combine (outputDir, "schema.xsd");
WriteSchema (fileName, schemas [0]);
}
else
{
for (int n=0; n<schemas.Count; n++)
{
string fileName = Path.Combine (outputDir, "schema" + n + ".xsd");
WriteSchema (fileName, schemas [n]);
}
}
}