本文整理汇总了C#中System.Xml.Serialization.XmlSchemaImporter.ImportTypeMapping方法的典型用法代码示例。如果您正苦于以下问题:C# XmlSchemaImporter.ImportTypeMapping方法的具体用法?C# XmlSchemaImporter.ImportTypeMapping怎么用?C# XmlSchemaImporter.ImportTypeMapping使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.Serialization.XmlSchemaImporter
的用法示例。
在下文中一共展示了XmlSchemaImporter.ImportTypeMapping方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateCode
public static CodeNamespace GenerateCode(Stream schemaStream, string classesNamespace)
{
// Open schema
XmlSchema schema = XmlSchema.Read(schemaStream, null);
XmlSchemas schemas = new XmlSchemas();
schemas.Add(schema);
schemas.Compile(null, true);
// Generate code
CodeNamespace code = new CodeNamespace(classesNamespace);
XmlSchemaImporter importer = new XmlSchemaImporter(schemas);
XmlCodeExporter exporter = new XmlCodeExporter(code);
foreach (XmlSchemaElement element in schema.Elements.Values) {
XmlTypeMapping mapping = importer.ImportTypeMapping(element.QualifiedName);
exporter.ExportTypeMapping(mapping);
}
// Modify generated code using extensions
schemaStream.Position = 0; // Rewind stream to the start
XPathDocument xPathDoc = new XPathDocument(schemaStream);
CodeGenerationContext context = new CodeGenerationContext(code, schema, xPathDoc);
new ExplicitXmlNamesExtension().ApplyTo(context);
new DocumentationExtension().ApplyTo(context);
new FixXmlTextAttributeExtension().ApplyTo(context);
new ArraysToGenericExtension().ApplyTo(context);
new CamelCaseExtension().ApplyTo(context);
new GetByIDExtension().ApplyTo(context);
return code;
}
示例2: Process
public static CodeNamespace Process(string xsdFile,
string targetNamespace)
{
// Load the XmlSchema and its collection.
XmlSchema xsd;
using (FileStream fs = new FileStream("Untitled1.xsd", FileMode.Open))
{
xsd = XmlSchema.Read(fs, null);
xsd.Compile(null);
}
XmlSchemas schemas = new XmlSchemas();
schemas.Add(xsd);
// Create the importer for these schemas.
XmlSchemaImporter importer = new XmlSchemaImporter(schemas);
// System.CodeDom namespace for the XmlCodeExporter to put classes in.
CodeNamespace ns = new CodeNamespace(targetNamespace);
XmlCodeExporter exporter = new XmlCodeExporter(ns);
// Iterate schema top-level elements and export code for each.
foreach (XmlSchemaElement element in xsd.Elements.Values)
{
// Import the mapping first.
XmlTypeMapping mapping = importer.ImportTypeMapping(
element.QualifiedName);
// Export the code finally.
exporter.ExportTypeMapping(mapping);
}
return ns;
}
示例3: Main
private static void Main(string[] args)
{
XmlSchema rootSchema = GetSchemaFromFile("fpml-main-4-2.xsd");
var schemaSet = new List<XmlSchemaExternal>();
ExtractIncludes(rootSchema, ref schemaSet);
var schemas = new XmlSchemas { rootSchema };
schemaSet.ForEach(schemaExternal => schemas.Add(GetSchemaFromFile(schemaExternal.SchemaLocation)));
schemas.Compile(null, true);
var xmlSchemaImporter = new XmlSchemaImporter(schemas);
var codeNamespace = new CodeNamespace("Hosca.FpML4_2");
var xmlCodeExporter = new XmlCodeExporter(codeNamespace);
var xmlTypeMappings = new List<XmlTypeMapping>();
foreach (XmlSchemaType schemaType in rootSchema.SchemaTypes.Values)
xmlTypeMappings.Add(xmlSchemaImporter.ImportSchemaType(schemaType.QualifiedName));
foreach (XmlSchemaElement schemaElement in rootSchema.Elements.Values)
xmlTypeMappings.Add(xmlSchemaImporter.ImportTypeMapping(schemaElement.QualifiedName));
xmlTypeMappings.ForEach(xmlCodeExporter.ExportTypeMapping);
CodeGenerator.ValidateIdentifiers(codeNamespace);
foreach (CodeTypeDeclaration codeTypeDeclaration in codeNamespace.Types)
{
for (int i = codeTypeDeclaration.CustomAttributes.Count - 1; i >= 0; i--)
{
CodeAttributeDeclaration cad = codeTypeDeclaration.CustomAttributes[i];
if (cad.Name == "System.CodeDom.Compiler.GeneratedCodeAttribute")
codeTypeDeclaration.CustomAttributes.RemoveAt(i);
}
}
using (var writer = new StringWriter())
{
new CSharpCodeProvider().GenerateCodeFromNamespace(codeNamespace, writer, new CodeGeneratorOptions());
//Console.WriteLine(writer.GetStringBuilder().ToString());
File.WriteAllText(Path.Combine(rootFolder, "FpML4_2.Generated.cs"), writer.GetStringBuilder().ToString());
}
Console.ReadLine();
}
示例4: ImportTypeMapping_Struct
public void ImportTypeMapping_Struct ()
{
XmlSchemas schemas = ExportType (typeof (TimeSpan));
ArrayList qnames = GetXmlQualifiedNames (schemas);
Assert.AreEqual (1, qnames.Count, "#1");
XmlSchemaImporter importer = new XmlSchemaImporter (schemas);
XmlTypeMapping map = importer.ImportTypeMapping ((XmlQualifiedName) qnames[0]);
Assert.IsNotNull (map, "#2");
Assert.AreEqual ("TimeSpan", map.ElementName, "#3");
Assert.AreEqual ("NSTimeSpan", map.Namespace, "#4");
Assert.AreEqual ("TimeSpan", map.TypeFullName, "#5");
Assert.AreEqual ("TimeSpan", map.TypeName, "#6");
}
示例5: ImportTypeMapping_XsdPrimitive_AnyType
[Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
public void ImportTypeMapping_XsdPrimitive_AnyType ()
{
XmlSchemas schemas = ExportType (typeof (object));
ArrayList qnames = GetXmlQualifiedNames (schemas);
Assert.AreEqual (1, qnames.Count, "#1");
XmlSchemaImporter importer = new XmlSchemaImporter (schemas);
XmlTypeMapping map = importer.ImportTypeMapping ((XmlQualifiedName) qnames[0]);
Assert.IsNotNull (map, "#2");
Assert.AreEqual ("anyType", map.ElementName, "#3");
Assert.AreEqual ("NSObject", map.Namespace, "#4");
Assert.AreEqual ("System.Object", map.TypeFullName, "#5");
Assert.AreEqual ("Object", map.TypeName, "#6");
}
示例6: GenerateCode
public static void GenerateCode(string xsdFilepath, string codeOutPath, string nameSpace)
{
FileStream stream = File.OpenRead(xsdFilepath);
XmlSchema xsd = XmlSchema.Read(stream, ValidationCallbackOne);
// Remove namespaceattribute from schema
xsd.TargetNamespace = null;
XmlSchemas xsds = new XmlSchemas { xsd };
XmlSchemaImporter imp = new XmlSchemaImporter(xsds);
//imp.Extensions.Add(new CustomSchemaImporterExtension());
CodeNamespace ns = new CodeNamespace(nameSpace);
XmlCodeExporter exp = new XmlCodeExporter(ns);
foreach (XmlSchemaObject item in xsd.Items)
{
if (!(item is XmlSchemaElement))
continue;
XmlSchemaElement xmlSchemaElement = (XmlSchemaElement)item;
XmlQualifiedName xmlQualifiedName = new XmlQualifiedName(xmlSchemaElement.Name, xsd.TargetNamespace);
XmlTypeMapping map = imp.ImportTypeMapping(xmlQualifiedName);
exp.ExportTypeMapping(map);
}
// Remove all the attributes from each type in the CodeNamespace, except
// System.Xml.Serialization.XmlTypeAttribute
RemoveAttributes(ns);
ToProperties(ns);
CodeCompileUnit compileUnit = new CodeCompileUnit();
compileUnit.Namespaces.Add(ns);
CSharpCodeProvider provider = new CSharpCodeProvider();
using (StreamWriter sw = new StreamWriter(codeOutPath, false))
{
CodeGeneratorOptions codeGeneratorOptions = new CodeGeneratorOptions();
provider.GenerateCodeFromCompileUnit(compileUnit, sw, codeGeneratorOptions);
}
}
示例7: GenerateClasses
private static void GenerateClasses(CodeNamespace code, XmlSchema schema)
{
XmlSchemas schemas = new XmlSchemas();
schemas.Add(schema);
XmlSchemaImporter importer = new XmlSchemaImporter(schemas);
CodeCompileUnit codeCompileUnit = new CodeCompileUnit();
CodeGenerationOptions options = CodeGenerationOptions.None;
XmlCodeExporter exporter = new XmlCodeExporter(code, codeCompileUnit, options);
foreach (XmlSchemaObject item in schema.Items)
{
XmlSchemaElement element = item as XmlSchemaElement;
if (element != null)
{
XmlQualifiedName name = new XmlQualifiedName(element.Name, schema.TargetNamespace);
XmlTypeMapping map = importer.ImportTypeMapping(name);
exporter.ExportTypeMapping(map);
}
}
}
示例8: Run
public void Run(string src, string dest)
{
// Load the schema to process.
XmlSchema xsd;
using (Stream stm = File.OpenRead(src))
xsd = XmlSchema.Read(stm, null);
// Collection of schemas for the XmlSchemaImporter
XmlSchemas xsds = new XmlSchemas();
xsds.Add(xsd);
XmlSchemaImporter imp = new XmlSchemaImporter(xsds);
// System.CodeDom namespace for the XmlCodeExporter to put classes in
CodeNamespace ns = new CodeNamespace("NHibernate.Mapping.Hbm");
CodeCompileUnit ccu = new CodeCompileUnit();
XmlCodeExporter exp = new XmlCodeExporter(ns, ccu, ~CodeGenerationOptions.GenerateProperties);
// Iterate schema items (top-level elements only) and generate code for each
foreach (XmlSchemaObject item in xsd.Items)
{
if (item is XmlSchemaElement)
{
// Import the mapping first
XmlTypeMapping map = imp.ImportTypeMapping(new XmlQualifiedName(((XmlSchemaElement)item).Name, xsd.TargetNamespace));
// Export the code finally
exp.ExportTypeMapping(map);
}
}
ns.Imports.Add(new CodeNamespaceImport("Ayende.NHibernateQueryAnalyzer.SchemaEditing"));
AddRequiredTags(ns, xsd);
// Code generator to build code with.
CodeDomProvider generator = new CSharpCodeProvider();
// Generate untouched version
using (StreamWriter sw = new StreamWriter(dest, false))
generator.GenerateCodeFromNamespace(ns, sw, new CodeGeneratorOptions());
}
示例9: GeneratedClassFromStream
private CodeNamespace GeneratedClassFromStream(Stream stream, string nameSpace)
{
XmlSchema xsd;
stream.Seek(0, SeekOrigin.Begin);
using (stream)
{
xsd = XmlSchema.Read(stream, null);
}
XmlSchemas xsds = new XmlSchemas();
xsds.Add(xsd);
xsds.Compile(null, true);
XmlSchemaImporter schemaImporter = new XmlSchemaImporter(xsds);
// create the codedom
CodeNamespace codeNamespace = new CodeNamespace(nameSpace);
XmlCodeExporter codeExporter = new XmlCodeExporter(codeNamespace);
List<XmlTypeMapping> maps = new List<XmlTypeMapping>();
foreach (XmlSchemaType schemaType in xsd.SchemaTypes.Values)
{
maps.Add(schemaImporter.ImportSchemaType(schemaType.QualifiedName));
}
foreach (XmlSchemaElement schemaElement in xsd.Elements.Values)
{
maps.Add(schemaImporter.ImportTypeMapping(schemaElement.QualifiedName));
}
foreach (XmlTypeMapping map in maps)
{
codeExporter.ExportTypeMapping(map);
}
this.RemoveUnusedStuff(codeNamespace);
return codeNamespace;
}
示例10: Process
public static CodeNamespace Process(string xsdSchema, string targetNamespace)
{
// Load the XmlSchema and its collection.
XmlSchema xsd;
using (var fs = new StringReader(xsdSchema))
{
xsd = XmlSchema.Read(fs, null);
xsd.Compile(null);
}
XmlSchemas schemas = new XmlSchemas();
schemas.Add(xsd);
// Create the importer for these schemas.
XmlSchemaImporter importer = new XmlSchemaImporter(schemas);
// System.CodeDom namespace for the XmlCodeExporter to put classes in.
CodeNamespace ns = new CodeNamespace(targetNamespace);
XmlCodeExporter exporter = new XmlCodeExporter(ns);
// Iterate schema top-level elements and export code for each.
foreach (XmlSchemaElement element in xsd.Elements.Values)
{
// Import the mapping first.
XmlTypeMapping mapping = importer.ImportTypeMapping(
element.QualifiedName);
// Export the code finally.
exporter.ExportTypeMapping(mapping);
}
// execute extensions
//var collectionsExt = new ArraysToCollectionsExtension();
//collectionsExt.Process(ns, xsd);
//var filedsExt = new FieldsToPropertiesExtension();
//filedsExt.Process(ns, xsd);
return ns;
}
示例11: GenerateClasses
public ObjectCollection GenerateClasses(XmlSchema schema)
{
#region Generate the CodeDom from the XSD
CodeNamespace codeNamespace = new CodeNamespace("TestNameSpace");
XmlSchemas xmlSchemas = new XmlSchemas();
xmlSchemas.Add(schema);
XmlSchemaImporter schemaImporter = new XmlSchemaImporter(xmlSchemas);
XmlCodeExporter codeExporter = new XmlCodeExporter(
codeNamespace,
new CodeCompileUnit(),
CodeGenerationOptions.GenerateProperties);
foreach (XmlSchemaElement element in schema.Elements.Values)
{
try
{
XmlTypeMapping map = schemaImporter.ImportTypeMapping(element.QualifiedName);
codeExporter.ExportTypeMapping(map);
}
catch (Exception ex)
{
throw new Exception("Error Loading Schema: ", ex);
}
}
#endregion
#region Modify the CodeDom
foreach (ICodeModifier codeModifier in m_codeModifiers)
codeModifier.Execute(codeNamespace);
#endregion
#region Generate the code
CodeCompileUnit compileUnit = new CodeCompileUnit();
compileUnit.Namespaces.Add(codeNamespace);
CodeDomProvider provider = CodeDomProvider.CreateProvider("CSharp");
#if DEBUG
StringWriter sw = new StringWriter();
CodeGeneratorOptions options = new CodeGeneratorOptions();
options.VerbatimOrder = true;
provider.GenerateCodeFromCompileUnit(compileUnit, sw, options);
m_codeString = sw.ToString();
#endif
#endregion
#region Compile an assembly
CompilerParameters compilerParameters = new CompilerParameters();
#region add references to assemblies
// reference for
// System.CodeDom.Compiler
// System.CodeDom
// System.Diagnostics
compilerParameters.ReferencedAssemblies.Add("System.dll");
compilerParameters.ReferencedAssemblies.Add("mscorlib.dll");
// System.Xml
compilerParameters.ReferencedAssemblies.Add("system.xml.dll");
// reference to this assembly for the custom collection editor
compilerParameters.ReferencedAssemblies.Add(Assembly.GetExecutingAssembly().Location);
compilerParameters.ReferencedAssemblies.Add("System.Drawing.dll");
// System.ComponentModel
#endregion
compilerParameters.GenerateExecutable = false;
compilerParameters.GenerateInMemory = true;
CompilerResults results = provider.CompileAssemblyFromDom(compilerParameters, new CodeCompileUnit[] { compileUnit });
// handle the errors if there are any
if (results.Errors.HasErrors)
{
m_errorStrings = new StringCollection();
m_errorStrings.Add("Error compiling assembly:\r\n");
foreach (CompilerError error in results.Errors)
m_errorStrings.Add(error.ErrorText + "\r\n");
return null;
}
#endregion
#region Find the exported classes
Assembly assembly = results.CompiledAssembly;
Type[] exportedTypes = assembly.GetExportedTypes();
// try to create an instance of the exported types
ObjectCollection objectCollection = new ObjectCollection();
objectCollection.Clear();
foreach (Type type in exportedTypes)
{
object obj = Activator.CreateInstance(type);
objectCollection.Add(new ObjectItem(type.Name, obj));
}
//.........这里部分代码省略.........
示例12: GenerateCode
/// <summary>
/// Generates the data contracts for given xsd file(s).
/// </summary>
public CodeNamespace GenerateCode()
{
CodeCompileUnit codeCompileUnit = new CodeCompileUnit();
CodeNamespace codeNamespace = new CodeNamespace(options.ClrNamespace);
codeCompileUnit.Namespaces.Add(codeNamespace);
// Build the code generation options.
GenerationOptions generationOptions = GenerationOptions.None;
if (options.GenerateProperties)
{
generationOptions |= GenerationOptions.GenerateProperties;
}
if (options.EnableDataBinding)
{
generationOptions |= GenerationOptions.EnableDataBinding;
}
if (options.GenerateOrderIdentifiers)
{
generationOptions |= GenerationOptions.GenerateOrder;
}
// Build the CodeDom object graph.
XmlCodeExporter codeExporter = new XmlCodeExporter(codeNamespace, codeCompileUnit, generationOptions, null);
CodeIdentifiers codeIdentifiers = new CodeIdentifiers();
ImportContext importContext = new ImportContext(codeIdentifiers, false);
XmlSchemaImporter schemaimporter = new XmlSchemaImporter(schemas, generationOptions, codeProvider, importContext);
for (int si = 0; si < schemas.Count; si++)
{
XmlSchema schema = schemas[si];
IEnumerator enumerator = schema.Elements.Values.GetEnumerator();
IEnumerator enumerator2 = schema.SchemaTypes.Values.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
XmlSchemaElement element = (XmlSchemaElement)enumerator.Current;
if (element.IsAbstract) continue;
XmlTypeMapping typemapping = schemaimporter.ImportTypeMapping(element.QualifiedName);
codeExporter.ExportTypeMapping(typemapping);
}
while (enumerator2.MoveNext())
{
XmlSchemaType type = (XmlSchemaType)enumerator2.Current;
if (CouldBeAnArray(type)) continue;
XmlTypeMapping typemapping = schemaimporter.ImportSchemaType(type.QualifiedName);
codeExporter.ExportTypeMapping(typemapping);
}
}
finally
{
IDisposable disposableobject = enumerator as IDisposable;
if (disposableobject != null)
{
disposableobject.Dispose();
}
IDisposable disposableobject2 = enumerator2 as IDisposable;
if (disposableobject2 != null)
{
disposableobject2.Dispose();
}
}
}
if (codeNamespace.Types.Count == 0)
{
throw new Exception("No types were generated.");
}
return codeNamespace;
}
示例13: Process
/// <summary>
/// Processes the schema.
/// </summary>
/// <param name="xsdFile">The full path to the WXS file to process.</param>
/// <param name="targetNamespace">The namespace to put generated classes in.</param>
/// <returns>The CodeDom tree generated from the schema.</returns>
public static CodeNamespace Process(string xsdFile, string targetNamespace, CodeDomProvider Provider)
{
// Load the XmlSchema and its collection.
//XmlSchema xsd;
//using ( FileStream fs = new FileStream( xsdFile, FileMode.Open ) )
//{
// xsd = XmlSchema.Read( fs, VH1 );
// xsd.Compile( VH2 );
//}
XmlSchemaSet set = new XmlSchemaSet();
XmlSchema xsd = set.Add(null, xsdFile);
set.Compile();
XmlSchemas schemas = new XmlSchemas();
schemas.Add(xsd);
// Create the importer for these schemas.
XmlSchemaImporter importer = new XmlSchemaImporter(schemas);
// System.CodeDom namespace for the XmlCodeExporter to put classes in.
CodeNamespace ns = new CodeNamespace(targetNamespace);
XmlCodeExporter exporter = new XmlCodeExporter(ns);
// Iterate schema top-level elements and export code for each.
foreach (XmlSchemaElement element in set.GlobalElements.Values) {
// Import the mapping first.
XmlTypeMapping mapping = importer.ImportTypeMapping(
element.QualifiedName);
// Export the code finally.
exporter.ExportTypeMapping(mapping);
}
#region Execute extensions
XPathNavigator nav;
using (FileStream fs = new FileStream(xsdFile, FileMode.Open, FileAccess.Read)) {
nav = new XPathDocument(fs).CreateNavigator();
}
XPathNodeIterator it = nav.Select(Extensions);
while (it.MoveNext()) {
Dictionary<string, string> values = ParsePEValue(it.Current.Value);
Type t = Type.GetType(values["extension-type"], true);
// Is the type an ICodeExtension?
Type iface = t.GetInterface(typeof(ICodeExtension).Name);
if (iface == null)
throw new ArgumentException(string.Format(Resources.ex_InvalidExtensionType, it.Current.Value));
ICodeExtension ext = (ICodeExtension)Activator.CreateInstance(t);
ext.Initialize(values);
// Run it!
ext.Process(ns, xsd, Provider);
}
#endregion Execute extensions
return ns;
}
示例14: ImportTypeMapping_XsdPrimitive_AnyURI
public void ImportTypeMapping_XsdPrimitive_AnyURI ()
{
string schemaFragment = "<?xml version=\"1.0\" encoding=\"utf-16\"?>" +
"<xs:schema xmlns:tns=\"NSAnyURI\" elementFormDefault=\"qualified\" targetNamespace=\"NSAnyURI\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">" +
" <xs:element name=\"anyURI\" type=\"xs:anyURI\" />" +
"</xs:schema>";
XmlSchemas schemas = new XmlSchemas ();
schemas.Add (XmlSchema.Read (new StringReader (schemaFragment), null));
ArrayList qnames = GetXmlQualifiedNames (schemas);
Assert.AreEqual (1, qnames.Count, "#1");
XmlQualifiedName qname = (XmlQualifiedName) qnames[0];
Assert.AreEqual ("anyURI", qname.Name, "#2");
Assert.AreEqual ("NSAnyURI", qname.Namespace, "#3");
XmlSchemaImporter importer = new XmlSchemaImporter (schemas);
XmlTypeMapping map = importer.ImportTypeMapping ((XmlQualifiedName) qnames[0]);
Assert.IsNotNull (map, "#4");
Assert.AreEqual ("anyURI", map.ElementName, "#5");
Assert.AreEqual ("NSAnyURI", map.Namespace, "#6");
Assert.AreEqual ("System.String", map.TypeFullName, "#7");
Assert.AreEqual ("String", map.TypeName, "#8");
}
示例15: ImportTypeMapping_EnumSimpleContent
public void ImportTypeMapping_EnumSimpleContent ()
{
string schemaFragment = "<?xml version=\"1.0\" encoding=\"utf-16\"?>" +
"<s:schema xmlns:tns=\"NSDate\" elementFormDefault=\"qualified\" targetNamespace=\"NSDate\" xmlns:s=\"http://www.w3.org/2001/XMLSchema\">" +
" <s:element name=\"trans\" type=\"tns:TranslationStatus\" />" +
" <s:complexType name=\"TranslationStatus\">" +
" <s:simpleContent>" +
" <s:extension base=\"tns:StatusType\">" +
" <s:attribute name=\"Language\" type=\"s:int\" use=\"required\" />" +
" </s:extension>" +
" </s:simpleContent>" +
" </s:complexType>" +
" <s:simpleType name=\"StatusType\">" +
" <s:restriction base=\"s:string\">" +
" <s:enumeration value=\"Untouched\" />" +
" <s:enumeration value=\"Touched\" />" +
" <s:enumeration value=\"Complete\" />" +
" <s:enumeration value=\"None\" />" +
" </s:restriction>" +
" </s:simpleType>" +
"</s:schema>";
XmlSchemas schemas = new XmlSchemas ();
schemas.Add (XmlSchema.Read (new StringReader (schemaFragment), null));
ArrayList qnames = GetXmlQualifiedNames (schemas);
Assert.AreEqual (1, qnames.Count, "#1");
XmlQualifiedName qname = (XmlQualifiedName) qnames[0];
Assert.AreEqual ("trans", qname.Name, "#2");
Assert.AreEqual ("NSDate", qname.Namespace, "#3");
XmlSchemaImporter importer = new XmlSchemaImporter (schemas);
XmlTypeMapping map = importer.ImportTypeMapping ((XmlQualifiedName) qnames[0]);
Assert.IsNotNull (map, "#4");
Assert.AreEqual ("trans", map.ElementName, "#5");
Assert.AreEqual ("NSDate", map.Namespace, "#6");
Assert.AreEqual ("TranslationStatus", map.TypeFullName, "#7");
Assert.AreEqual ("TranslationStatus", map.TypeName, "#8");
CodeNamespace codeNamespace = ExportCode (map);
Assert.IsNotNull (codeNamespace, "#9");
CodeTypeDeclaration type = FindType (codeNamespace, "TranslationStatus");
Assert.IsNotNull (type, "#10");
#if NET_2_0
CodeMemberProperty property = FindMember (type, "Value") as CodeMemberProperty;
Assert.IsNotNull (property, "#A1");
Assert.IsTrue (property.HasGet, "#A2");
Assert.IsTrue (property.HasSet, "#A3");
Assert.AreEqual ("StatusType", property.Type.BaseType, "#A4");
CodeMemberField field = FindMember (type, "valueField") as CodeMemberField;
Assert.IsNotNull (field, "#A5");
Assert.AreEqual ("StatusType", field.Type.BaseType, "#A6");
property = FindMember (type, "Language") as CodeMemberProperty;
Assert.IsNotNull (property, "#B1");
Assert.IsTrue (property.HasGet, "#B2");
Assert.IsTrue (property.HasSet, "#B3");
Assert.AreEqual ("System.Int32", property.Type.BaseType, "#B4");
field = FindMember (type, "languageField") as CodeMemberField;
Assert.IsNotNull (field, "#B5");
Assert.AreEqual ("System.Int32", field.Type.BaseType, "#B6");
#else
CodeMemberField field = FindMember (type, "Value") as CodeMemberField;
Assert.IsNotNull (field, "#A1");
Assert.AreEqual ("StatusType", field.Type.BaseType, "#A2");
field = FindMember (type, "Language") as CodeMemberField;
Assert.IsNotNull (field, "#B1");
Assert.AreEqual ("System.Int32", field.Type.BaseType, "#B2");
#endif
}