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/BindDatabaseCommand.cs | 6 ++++- .../Bind/CabinetResolver.cs | 28 +++++++++++++++++----- .../Bind/CreateCabinetsCommand.cs | 8 +++++-- 3 files changed, 33 insertions(+), 9 deletions(-) (limited to 'src/WixToolset.Core.WindowsInstaller/Bind') diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs index 020f58b3..f78cb42c 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs @@ -24,6 +24,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind public BindDatabaseCommand(IBindContext context, IEnumerable backendExtension, Validator validator) { + this.ServiceProvider = context.ServiceProvider; + this.Messaging = context.ServiceProvider.GetService(); this.BackendHelper = context.ServiceProvider.GetService(); @@ -46,6 +48,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind this.BackendExtensions = backendExtension; } + public IServiceProvider ServiceProvider { get; } + private IMessaging Messaging { get; } private IBackendHelper BackendHelper { get; } @@ -383,7 +387,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind { this.Messaging.Write(VerboseMessages.CreatingCabinetFiles()); - var command = new CreateCabinetsCommand(this.BackendHelper); + var command = new CreateCabinetsCommand(this.ServiceProvider, this.BackendHelper); command.CabbingThreadCount = this.CabbingThreadCount; command.CabCachePath = this.CabCachePath; command.DefaultCompressionLevel = this.DefaultCompressionLevel; 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 diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs index 88be831e..890c446c 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs @@ -34,7 +34,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind private Dictionary lastCabinetAddedToMediaTable; // Key is First Cabinet Name, Value is Last Cabinet Added in the Split Sequence - public CreateCabinetsCommand(IBackendHelper backendHelper) + public CreateCabinetsCommand(IServiceProvider serviceProvider, IBackendHelper backendHelper) { this.fileTransfers = new List(); @@ -42,9 +42,13 @@ namespace WixToolset.Core.WindowsInstaller.Bind this.newCabNamesCallBack = this.NewCabNamesCallBack; + this.ServiceProvider = serviceProvider; + this.BackendHelper = backendHelper; } + public IServiceProvider ServiceProvider { get; } + public IBackendHelper BackendHelper { get; } /// @@ -221,7 +225,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind } } - var cabinetResolver = new CabinetResolver(this.CabCachePath, this.BackendExtensions); + var cabinetResolver = new CabinetResolver(this.ServiceProvider, this.CabCachePath, this.BackendExtensions); var resolvedCabinet = cabinetResolver.ResolveCabinet(tempCabinetFileX, fileFacades); -- cgit v1.2.3-55-g6feb