Пример #1
0
        private static void MergeOptionsToConfig(PdfCommandOptions options, PdfJsonConfig config)
        {
            BuildCommand.MergeOptionsToConfig(options, config);

            if (options.ExcludedTocs?.Count > 0)
            {
                config.ExcludedTocs = new ListWithStringFallback(options.ExcludedTocs);
            }

            if (!string.IsNullOrEmpty(options.CssFilePath))
            {
                config.CssFilePath = options.CssFilePath;
            }

            if (!string.IsNullOrEmpty(options.Name))
            {
                config.Name = options.Name;
            }

            if (!string.IsNullOrEmpty(options.Host))
            {
                config.Host = options.Host;
            }

            if (!string.IsNullOrEmpty(options.Locale))
            {
                config.Locale = options.Locale;
            }

            if (!string.IsNullOrEmpty(options.BasePath))
            {
                config.BasePath = options.BasePath;
            }

            if (!string.IsNullOrEmpty(options.RawOutputFolder))
            {
                config.RawOutputFolder = options.RawOutputFolder;
            }

            if (!string.IsNullOrEmpty(options.LoadErrorHandling))
            {
                config.LoadErrorHandling = options.LoadErrorHandling;
            }

            if (options.GeneratesAppendices.HasValue)
            {
                config.GeneratesAppendices = options.GeneratesAppendices.Value;
            }

            if (options.KeepRawFiles.HasValue)
            {
                config.KeepRawFiles = options.KeepRawFiles.Value;
            }

            if (options.GeneratesExternalLink.HasValue)
            {
                config.GeneratesExternalLink = options.GeneratesExternalLink.Value;
            }

            if (options.NoInputStreamArgs.HasValue)
            {
                config.NoInputStreamArgs = options.NoInputStreamArgs.Value;
            }
        }
Пример #2
0
        public void TestParseCommandOptionWithConfigFileAndMetadataFilePathAndMetadatFilePaths()
        {
            var config = new BuildCommand(new BuildCommandOptions
            {
                ConfigFile = _configFile,
                GlobalMetadataFilePaths = new List<string>
                {
                    Path.GetFullPath(_globalMetadataFile1),
                    Path.GetFullPath(_globalMetadataFile2)
                },
                GlobalMetadataFilePath = Path.GetFullPath(_deprecatedGlobalMetdataFile),
                FileMetadataFilePath = Path.GetFullPath(_deprecatedFileMetadataFile),
                FileMetadataFilePaths = new List<string>
                {
                    Path.GetFullPath(_fileMetadataFile1),
                    Path.GetFullPath(_fileMetadataFile2)
                }
            }).Config;
            Assert.Equal("global2.json", config.GlobalMetadata["key"]);
            Assert.Equal("1", config.GlobalMetadata["global1"]);
            Assert.Equal("2", config.GlobalMetadata["global2"]);
            Assert.Equal("deprecated", config.GlobalMetadata["global.deprecated"]);

            var actual = config.FileMetadata["key"].Items.Select(item => $"{item.Glob.Raw}: {item.Value.ToString()}").ToList();
            Assert.Equal(new List<string>
            {
                "filepattern1: string",
                "filePattern2: 2",
                "filePattern3: True",
                "filePattern4: System.Object[]",
                "filePattern5: System.Collections.Generic.Dictionary`2[System.String,System.Object]",
                "filepattern1: file.deprecated.json",
                "filepattern1: file1.json",
                "filepattern1: file2.json"
            }, actual);
        }
Пример #3
0
 public void TestParseCommandOptionWithConfigFileAndMetadataFilePathAndMetadatFilePathsAndMetadata()
 {
     var config = new BuildCommand(new BuildCommandOptions
     {
         ConfigFile = _configFile,
         GlobalMetadata = "{\"key\": \"--globalMetadata\"}",
         GlobalMetadataFilePaths = new List<string>
         {
             Path.GetFullPath(_globalMetadataFile1),
             Path.GetFullPath(_globalMetadataFile2)
         },
         GlobalMetadataFilePath = Path.GetFullPath(_deprecatedGlobalMetdataFile)
     }).Config;
     Assert.Equal("--globalMetadata", config.GlobalMetadata["key"]);
     Assert.Equal("1", config.GlobalMetadata["global1"]);
     Assert.Equal("2", config.GlobalMetadata["global2"]);
     Assert.Equal("deprecated", config.GlobalMetadata["global.deprecated"]);
 }
Пример #4
0
        public void TestParseCommandOptionWithOnlyConfigFile()
        {

            var config = new BuildCommand(new BuildCommandOptions
            {
                ConfigFile = _configFile,
            }).Config;
            Assert.Equal("value", config.GlobalMetadata["key"]);

            var actual = config.FileMetadata["key"].Items.Select(item => $"{item.Glob.Raw}: {item.Value.ToString()}").ToList();
            Assert.Equal(new List<string>
            {
                "filepattern1: string",
                "filePattern2: 2",
                "filePattern3: True",
                "filePattern4: System.Object[]",
                "filePattern5: System.Collections.Generic.Dictionary`2[System.String,System.Object]"
            }, actual);
        }