Ejemplo n.º 1
0
 internal int Add(string name, SchemaImporterExtension extension)
 {
     if (Names[name] != null)
     {
         if (Names[name].GetType() != extension.GetType())
         {
             throw new InvalidOperationException(string.Format(ResXml.XmlConfigurationDuplicateExtension, name));
         }
         return(-1);
     }
     Names[name] = extension;
     return(List.Add(extension));
 }
Ejemplo n.º 2
0
        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 = string.Format(ResXml.XmlExtensionComment, _extension.GetType().FullName);

            foreach (CodeTypeDeclaration type in _code.Types)
            {
                if (_clrType == type.Name)
                {
                    if (codeClass != null)
                    {
                        throw new InvalidOperationException(string.Format(ResXml.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);
        }
Ejemplo n.º 3
0
 public int Add(SchemaImporterExtension extension)
 {
     return(Add(extension.GetType().FullName, extension));
 }