From dbde9e7104b907bbbaea17e21247d8cafc8b3a4c Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Sat, 14 Oct 2017 16:12:07 -0700 Subject: Massive refactoring to introduce the concept of IBackend --- src/WixToolset.Core/Librarian.cs | 43 +++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) (limited to 'src/WixToolset.Core/Librarian.cs') diff --git a/src/WixToolset.Core/Librarian.cs b/src/WixToolset.Core/Librarian.cs index 66a8c32d..092d81dc 100644 --- a/src/WixToolset.Core/Librarian.cs +++ b/src/WixToolset.Core/Librarian.cs @@ -1,10 +1,11 @@ // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -namespace WixToolset +namespace WixToolset.Core { using System; using System.Collections.Generic; using System.Linq; + using WixToolset.Core.Bind; using WixToolset.Data; using WixToolset.Link; @@ -13,20 +14,41 @@ namespace WixToolset /// public sealed class Librarian { + public Librarian(LibraryContext context) + { + this.Context = context; + } + + private LibraryContext Context { get; } + /// /// Create a library by combining several intermediates (objects). /// /// The sections to combine into a library. /// Returns the new library. - public Library Combine(IEnumerable
sections, IEnumerable localizations, ILibraryBinaryFileResolver resolver) + public Library Combine() { - var localizationsByCulture = CollateLocalizations(localizations); + foreach (var extension in this.Context.Extensions) + { + extension.PreCombine(this.Context); + } + + var fileResolver = new FileResolver(this.Context.BindPaths, this.Context.Extensions); - var embedFilePaths = ResolveFilePathsToEmbed(sections, resolver); + var localizationsByCulture = CollateLocalizations(this.Context.Localizations); - var library = new Library(sections, localizationsByCulture, embedFilePaths); + var embedFilePaths = ResolveFilePathsToEmbed(this.Context.Sections, fileResolver); - return this.Validate(library); + var library = new Library(this.Context.Sections, localizationsByCulture, embedFilePaths); + + this.Validate(library); + + foreach (var extension in this.Context.Extensions) + { + extension.PostCombine(library); + } + + return library; } /// @@ -70,12 +92,12 @@ namespace WixToolset return localizationsByCulture; } - private static List ResolveFilePathsToEmbed(IEnumerable
sections, ILibraryBinaryFileResolver resolver) + private List ResolveFilePathsToEmbed(IEnumerable
sections, FileResolver fileResolver) { var embedFilePaths = new List(); // Resolve paths to files that are to be embedded in the library. - if (null != resolver) + if (this.Context.BindFiles) { foreach (Table table in sections.SelectMany(s => s.Tables)) { @@ -85,7 +107,10 @@ namespace WixToolset { if (null != objectField.Data) { - string file = resolver.Resolve(row.SourceLineNumbers, table.Name, (string)objectField.Data); + string resolvedPath = this.Context.WixVariableResolver.ResolveVariables(row.SourceLineNumbers, (string)objectField.Data, false); + + string file = fileResolver.Resolve(row.SourceLineNumbers, table.Name, resolvedPath); + if (!String.IsNullOrEmpty(file)) { // File was successfully resolved so track the embedded index as the embedded file index. -- cgit v1.2.3-55-g6feb