From 5392cf57c09bddde7157e5b26c5c2a013f819ead Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Fri, 1 Mar 2019 11:12:52 -0800 Subject: Integrate interface-only WixToolset.Extensibility change --- .../Bind/CabinetResolver.cs | 28 +++++++++++++++++----- 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'src/WixToolset.Core.WindowsInstaller/Bind/CabinetResolver.cs') diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/CabinetResolver.cs b/src/WixToolset.Core.WindowsInstaller/Bind/CabinetResolver.cs index 2a717ec5..054e3c71 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/CabinetResolver.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/CabinetResolver.cs @@ -1,4 +1,4 @@ -// 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. +// 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.Core.WindowsInstaller.Bind { @@ -11,25 +11,30 @@ namespace WixToolset.Core.WindowsInstaller.Bind using WixToolset.Data; using WixToolset.Extensibility; using WixToolset.Extensibility.Data; + using WixToolset.Extensibility.Services; public class CabinetResolver { - public CabinetResolver(string cabCachePath, IEnumerable backendExtensions) + public CabinetResolver(IServiceProvider serviceProvider, string cabCachePath, IEnumerable backendExtensions) { + this.ServiceProvider = serviceProvider; + this.CabCachePath = cabCachePath; this.BackendExtensions = backendExtensions; } + private IServiceProvider ServiceProvider { get; } + private string CabCachePath { get; } private IEnumerable BackendExtensions { get; } - public ResolvedCabinet ResolveCabinet(string cabinetPath, IEnumerable fileFacades) + public IResolvedCabinet ResolveCabinet(string cabinetPath, IEnumerable fileFacades) { - var filesWithPath = fileFacades.Select(f => new BindFileWithPath() { Id = f.File.File, Path = f.WixFile.Source.Path }).ToList(); + var filesWithPath = fileFacades.Select(this.CreateBindFileWithPath).ToList(); - ResolvedCabinet resolved = null; + IResolvedCabinet resolved = null; foreach (var extension in this.BackendExtensions) { @@ -42,7 +47,9 @@ namespace WixToolset.Core.WindowsInstaller.Bind } // By default cabinet should be built and moved to the suggested location. - resolved = new ResolvedCabinet() { BuildOption = CabinetBuildOption.BuildAndMove, Path = cabinetPath }; + resolved = this.ServiceProvider.GetService(); + resolved.BuildOption = CabinetBuildOption.BuildAndMove; + resolved.Path = cabinetPath; // If a cabinet cache path was provided, change the location for the cabinet // to be built to and check if there is a cabinet that can be reused. @@ -102,6 +109,15 @@ namespace WixToolset.Core.WindowsInstaller.Bind return resolved; } + private IBindFileWithPath CreateBindFileWithPath(FileFacade facade) + { + var result = this.ServiceProvider.GetService(); + result.Id = facade.File.File; + result.Path = facade.WixFile.Source.Path; + + return result; + } + private static bool CheckFileExists(string path) { try -- cgit v1.2.3-55-g6feb