System.Xml.Serialization.Advanced.MappedTypeDesc.ExportTypeDefinition C# (CSharp) Method

ExportTypeDefinition() private method

private ExportTypeDefinition ( CodeNamespace codeNamespace, CodeCompileUnit codeCompileUnit ) : CodeTypeDeclaration
codeNamespace System.CodeDom.CodeNamespace
codeCompileUnit System.CodeDom.CodeCompileUnit
return System.CodeDom.CodeTypeDeclaration
        internal CodeTypeDeclaration ExportTypeDefinition(CodeNamespace codeNamespace, CodeCompileUnit codeCompileUnit) {
            if (exported)
                return null;
            exported = true;

            foreach(CodeNamespaceImport import in code.Imports) {
                codeNamespace.Imports.Add(import);
            }
            CodeTypeDeclaration codeClass = null;
            string comment = Res.GetString(Res.XmlExtensionComment, extension.GetType().FullName);
            foreach(CodeTypeDeclaration type in code.Types) {
                if (clrType == type.Name) {
                    if (codeClass != null)
                        throw new InvalidOperationException(Res.GetString(Res.XmlExtensionDuplicateDefinition, extension.GetType().FullName, clrType));
                    codeClass = type;
                }
                type.Comments.Add(new CodeCommentStatement(comment, false));
                codeNamespace.Types.Add(type);
            }
            if (codeCompileUnit != null) {
                foreach(string reference in ReferencedAssemblies) {
                    if (codeCompileUnit.ReferencedAssemblies.Contains(reference))
                        continue;
                    codeCompileUnit.ReferencedAssemblies.Add(reference);
                }
            }
            return codeClass;
        }
    }