public void Generate(IMetadataSource source, IMetadataReferenceResolver metadataReferenceResolver, IMetadataWriter writer)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }
            if (writer == null)
            {
                throw new ArgumentNullException(nameof(writer));
            }

            writer.Write(new IgnoredNamespaceFilter(source, IgnoredNamespaces, metadataReferenceResolver), WriteAssemblyMetadata);
        }
Exemplo n.º 2
0
        public ExitCode Execute()
        {
            const int RequiredArgs = 2;

            if (_args.Count < RequiredArgs)
            {
                _outputWriter.Output.WriteLine(StringResources.HelpMetadataDotnetParameters);
                return(ExitCode.Error);
            }

            string assemblyname    = _args[0];
            string filename        = _args[1];
            string namespaceFilter = _args.Count > RequiredArgs
                ? _args[2]
                : "*";

            var assemblyModel = _assemblyReader.Read(assemblyname, namespaceFilter);

            if (assemblyModel == null)
            {
                return(ExitCode.Error);
            }

            var document = _metadataWriter.Write(assemblyModel);

            if (document == null)
            {
                return(ExitCode.Error);
            }

            try
            {
                document.Save(filename);
            }
            catch (XmlException ex)
            {
                _outputWriter.Output.WriteLine(
                    string.Format(StringResources.ErrorSavingMetadataFile, filename, ex.Message));

                return(ExitCode.Error);
            }

            return(ExitCode.Success);
        }
Exemplo n.º 3
0
        public ExitCode Execute()
        {
            const int RequiredArgs = 2;

            if (_args.Count < RequiredArgs)
            {
                _outputWriter.Output.WriteLine(StringResources.HelpMetadataDbParameters);
                return(ExitCode.Error);
            }

            string connectionString = _args[0];
            string filename         = _args[1];

            var dbModel = _schemaReader.Read(connectionString);

            if (dbModel == null)
            {
                return(ExitCode.Error);
            }

            var document = _metadataWriter.Write(dbModel);

            if (document == null)
            {
                return(ExitCode.Error);
            }

            try
            {
                document.Save(filename);
            }
            catch (XmlException ex)
            {
                _outputWriter.Output.WriteLine(
                    string.Format(StringResources.ErrorSavingMetadataFile, filename, ex.Message));

                return(ExitCode.Error);
            }

            return(ExitCode.Success);
        }