public IManifestEntry CompileOne(string inputFile, PreviewGenerationOptions previewOptions, bool allConfigurations, IDictionary <IOutputGenerator, string> formats) { logger.LogInformation(inputFile); var loader = new XmlLoader(); using (var fs = File.OpenRead(inputFile)) { if (!loader.Load(fs, logger, out var description)) { Environment.Exit(1); } var baseName = Path.GetFileNameWithoutExtension(inputFile); var outputs = outputRunner.Generate(fs, description, null, baseName, formats, previewOptions, SourceFileType.ComponentDescription).ToList(); Dictionary <string, IReadOnlyDictionary <string, string> > configurationOutputs = new Dictionary <string, IReadOnlyDictionary <string, string> >(); if (allConfigurations) { foreach (var configuration in description.Metadata.Configurations) { var renderOptions = new PreviewGenerationOptions { Center = previewOptions.Center, Crop = previewOptions.Crop, DebugLayout = previewOptions.DebugLayout, Width = previewOptions.Width, Height = previewOptions.Height, Horizontal = previewOptions.Horizontal, Size = previewOptions.Size, Configuration = configuration.Name, }; var configurationOutput = outputRunner.Generate(fs, description, configuration, baseName, formats, renderOptions, SourceFileType.ComponentDescriptionConfiguration); configurationOutputs[configuration.Name] = configurationOutput.ToImmutableDictionary(); } } var metadata = description.Metadata.Entries.ToDictionary(x => x.Key, x => x.Value); var svgIcon = GetSvgIconPath(Path.GetDirectoryName(inputFile), description); if (svgIcon != null) { metadata["org.circuit-diagram.icon-svg"] = svgIcon; } return(new ComponentDescriptionManifestEntry { Author = description.Metadata.Author, ComponentName = description.ComponentName, ComponentGuid = description.Metadata.GUID, Success = true, Description = description.Metadata.AdditionalInformation, Version = description.Metadata.Version.ToString(), InputFile = CleanPath(inputFile), Metadata = metadata, OutputFiles = outputs.ToImmutableDictionary(), ConfigurationOutputFiles = configurationOutputs, }); } }
public IManifestEntry CompileOne(string inputFile, PreviewGenerationOptions previewOptions, IDictionary <IOutputGenerator, string> formats) { logger.LogInformation(inputFile); var reader = new ConfigurationDefinitionReader(componentDescriptionLookup); using (var fs = File.OpenRead(inputFile)) { var configurationDefinition = reader.ReadDefinition(fs); var renderOptions = new PreviewGenerationOptions { Center = previewOptions.Center, Crop = previewOptions.Crop, DebugLayout = previewOptions.DebugLayout, Width = previewOptions.Width, Height = previewOptions.Height, Horizontal = previewOptions.Horizontal, Size = previewOptions.Size, RawProperties = configurationDefinition.Configuration.Setters, }; var outputs = outputRunner.Generate(fs, configurationDefinition.ComponentDescription, configurationDefinition.Configuration, Path.GetFileNameWithoutExtension(inputFile), formats, renderOptions, SourceFileType.ConfigurationDefinition); return(new ComponentConfigurationManifestEntry { Metadata = configurationDefinition.Metadata, InputFile = ComponentDescriptionRunner.CleanPath(inputFile), ComponentGuid = configurationDefinition.ComponentDescription.Metadata.GUID, ConfigurationName = configurationDefinition.Configuration.Name, OutputFiles = outputs.ToImmutableDictionary(), }); } }