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 +++++-- .../Decompile/DecompileMsiOrMsmCommand.cs | 4 ++-- src/WixToolset.Core.WindowsInstaller/MsiBackend.cs | 8 ++++--- src/WixToolset.Core.WindowsInstaller/MsmBackend.cs | 8 ++++--- src/WixToolset.Core.WindowsInstaller/MspBackend.cs | 4 ++-- src/WixToolset.Core.WindowsInstaller/MstBackend.cs | 4 ++-- 8 files changed, 49 insertions(+), 21 deletions(-) (limited to 'src/WixToolset.Core.WindowsInstaller') 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); diff --git a/src/WixToolset.Core.WindowsInstaller/Decompile/DecompileMsiOrMsmCommand.cs b/src/WixToolset.Core.WindowsInstaller/Decompile/DecompileMsiOrMsmCommand.cs index a98b4584..d44a863d 100644 --- a/src/WixToolset.Core.WindowsInstaller/Decompile/DecompileMsiOrMsmCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Decompile/DecompileMsiOrMsmCommand.cs @@ -28,9 +28,9 @@ namespace WixToolset.Core.WindowsInstaller.Unbind private IMessaging Messaging { get; } - public DecompileResult Execute() + public IDecompileResult Execute() { - var result = new DecompileResult(); + var result = this.Context.ServiceProvider.GetService(); try { diff --git a/src/WixToolset.Core.WindowsInstaller/MsiBackend.cs b/src/WixToolset.Core.WindowsInstaller/MsiBackend.cs index b633ea31..f105473b 100644 --- a/src/WixToolset.Core.WindowsInstaller/MsiBackend.cs +++ b/src/WixToolset.Core.WindowsInstaller/MsiBackend.cs @@ -13,7 +13,7 @@ namespace WixToolset.Core.WindowsInstaller internal class MsiBackend : IBackend { - public BindResult Bind(IBindContext context) + public IBindResult Bind(IBindContext context) { var extensionManager = context.ServiceProvider.GetService(); @@ -29,7 +29,9 @@ namespace WixToolset.Core.WindowsInstaller var command = new BindDatabaseCommand(context, backendExtensions, validator); command.Execute(); - var result = new BindResult { FileTransfers = command.FileTransfers, TrackedFiles = command.TrackedFiles }; + var result = context.ServiceProvider.GetService(); + result.FileTransfers = command.FileTransfers; + result.TrackedFiles = command.TrackedFiles; foreach (var extension in backendExtensions) { @@ -38,7 +40,7 @@ namespace WixToolset.Core.WindowsInstaller return result; } - public DecompileResult Decompile(IDecompileContext context) + public IDecompileResult Decompile(IDecompileContext context) { var extensionManager = context.ServiceProvider.GetService(); diff --git a/src/WixToolset.Core.WindowsInstaller/MsmBackend.cs b/src/WixToolset.Core.WindowsInstaller/MsmBackend.cs index 84588572..d17aad8e 100644 --- a/src/WixToolset.Core.WindowsInstaller/MsmBackend.cs +++ b/src/WixToolset.Core.WindowsInstaller/MsmBackend.cs @@ -12,7 +12,7 @@ namespace WixToolset.Core.WindowsInstaller internal class MsmBackend : IBackend { - public BindResult Bind(IBindContext context) + public IBindResult Bind(IBindContext context) { var extensionManager = context.ServiceProvider.GetService(); @@ -28,7 +28,9 @@ namespace WixToolset.Core.WindowsInstaller var command = new BindDatabaseCommand(context, backendExtensions, validator); command.Execute(); - var result = new BindResult { FileTransfers = command.FileTransfers, TrackedFiles = command.TrackedFiles }; + var result = context.ServiceProvider.GetService(); + result.FileTransfers = command.FileTransfers; + result.TrackedFiles = command.TrackedFiles; foreach (var extension in backendExtensions) { @@ -43,7 +45,7 @@ namespace WixToolset.Core.WindowsInstaller return result; } - public DecompileResult Decompile(IDecompileContext context) + public IDecompileResult Decompile(IDecompileContext context) { var extensionManager = context.ServiceProvider.GetService(); diff --git a/src/WixToolset.Core.WindowsInstaller/MspBackend.cs b/src/WixToolset.Core.WindowsInstaller/MspBackend.cs index df4eb44c..90e67336 100644 --- a/src/WixToolset.Core.WindowsInstaller/MspBackend.cs +++ b/src/WixToolset.Core.WindowsInstaller/MspBackend.cs @@ -16,12 +16,12 @@ namespace WixToolset.Core.WindowsInstaller internal class MspBackend : IBackend { - public BindResult Bind(IBindContext context) + public IBindResult Bind(IBindContext context) { throw new NotImplementedException(); } - public DecompileResult Decompile(IDecompileContext context) + public IDecompileResult Decompile(IDecompileContext context) { throw new NotImplementedException(); } diff --git a/src/WixToolset.Core.WindowsInstaller/MstBackend.cs b/src/WixToolset.Core.WindowsInstaller/MstBackend.cs index 6460821a..b64f417a 100644 --- a/src/WixToolset.Core.WindowsInstaller/MstBackend.cs +++ b/src/WixToolset.Core.WindowsInstaller/MstBackend.cs @@ -10,7 +10,7 @@ namespace WixToolset.Core.WindowsInstaller internal class MstBackend : IBackend { - public BindResult Bind(IBindContext context) + public IBindResult Bind(IBindContext context) { #if REVISIT_FOR_PATCHING var command = new BindTransformCommand(); @@ -25,7 +25,7 @@ namespace WixToolset.Core.WindowsInstaller throw new NotImplementedException(); } - public DecompileResult Decompile(IDecompileContext context) + public IDecompileResult Decompile(IDecompileContext context) { throw new NotImplementedException(); } -- cgit v1.2.3-55-g6feb