Beispiel #1
0
    protected virtual async Task Write(IEnumerable <PluginRecord> data, IFileOutputFormatterOptions options)
    {
        if (options is null)
        {
            throw new ArgumentNullException(nameof(options));
        }

        if (string.IsNullOrWhiteSpace(options.Path))
        {
            throw new ArgumentException(nameof(options.Path));
        }

        var lines = new List <string>();

        var allByPath = data
                        .OrderBy(pair => pair.ProjectDescriptor.Path)
                        .ThenBy(pair => pair.PluginDescriptor.Name)
                        .ToLookup(pair => pair.ProjectDescriptor.Path, pair => pair.PluginDescriptor.Name);

        lines.AddRange(ToLines(allByPath));

        var allByVst = data
                       .OrderBy(pair => pair.PluginDescriptor.Name)
                       .ThenBy(pair => pair.ProjectDescriptor.Path)
                       .ToLookup(pair => pair.PluginDescriptor.Name, e => e.ProjectDescriptor.Path);

        lines.AddRange(ToLines(allByVst));

        await File.WriteAllLinesAsync(options.Path, lines);
    }
Beispiel #2
0
    protected virtual async Task Write(IEnumerable <PluginRecord> data, IFileOutputFormatterOptions options)
    {
        if (options is null)
        {
            throw new ArgumentNullException(nameof(options));
        }

        if (string.IsNullOrWhiteSpace(options.Path))
        {
            throw new ArgumentException(nameof(options.Path));
        }

        var document = Document.Create("List of VSTs");

        var detailsList = data.ToList();

        var projectSection = new ProjectSection();

        projectSection.Add(detailsList);

        var pluginSection = new PluginSection();

        pluginSection.Add(detailsList);

        var mainIndex = new MainIndex("main-index", "Main index");

        mainIndex.Add(new ISection[] { projectSection, pluginSection });

        document.AddMainIndex(mainIndex);
        document.AddSection(projectSection);
        document.AddSection(pluginSection);

        document.Save(options.Path);
        await Task.CompletedTask;
    }