diff options
| author | Rob Mensching <rob@firegiant.com> | 2021-03-14 07:38:48 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2021-03-14 07:47:48 -0700 |
| commit | 3ccd5e439da4296d6f2b66ce47075ab20d039676 (patch) | |
| tree | b5546552613b869367d09f444492a0bbcfadcfe0 /src/WixToolset.Core.WindowsInstaller/Bind/AssignMediaCommand.cs | |
| parent | 574785ab1421c9b67336c13ade5c2263e665ca07 (diff) | |
| download | wix-3ccd5e439da4296d6f2b66ce47075ab20d039676.tar.gz wix-3ccd5e439da4296d6f2b66ce47075ab20d039676.tar.bz2 wix-3ccd5e439da4296d6f2b66ce47075ab20d039676.zip | |
Minimize public surface area of Core
Fixes wixtoolset/issues#6374
Diffstat (limited to 'src/WixToolset.Core.WindowsInstaller/Bind/AssignMediaCommand.cs')
| -rw-r--r-- | src/WixToolset.Core.WindowsInstaller/Bind/AssignMediaCommand.cs | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/AssignMediaCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/AssignMediaCommand.cs index f6c61866..d7faa382 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/AssignMediaCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/AssignMediaCommand.cs | |||
| @@ -6,9 +6,9 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 6 | using System.Collections.Generic; | 6 | using System.Collections.Generic; |
| 7 | using System.Globalization; | 7 | using System.Globalization; |
| 8 | using System.Linq; | 8 | using System.Linq; |
| 9 | using WixToolset.Core.Bind; | ||
| 10 | using WixToolset.Data; | 9 | using WixToolset.Data; |
| 11 | using WixToolset.Data.Symbols; | 10 | using WixToolset.Data.Symbols; |
| 11 | using WixToolset.Extensibility.Data; | ||
| 12 | using WixToolset.Extensibility.Services; | 12 | using WixToolset.Extensibility.Services; |
| 13 | 13 | ||
| 14 | /// <summary> | 14 | /// <summary> |
| @@ -18,7 +18,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 18 | { | 18 | { |
| 19 | private const int DefaultMaximumUncompressedMediaSize = 200; // Default value is 200 MB | 19 | private const int DefaultMaximumUncompressedMediaSize = 200; // Default value is 200 MB |
| 20 | 20 | ||
| 21 | public AssignMediaCommand(IntermediateSection section, IMessaging messaging, IEnumerable<FileFacade> fileFacades, bool compressed) | 21 | public AssignMediaCommand(IntermediateSection section, IMessaging messaging, IEnumerable<IFileFacade> fileFacades, bool compressed) |
| 22 | { | 22 | { |
| 23 | this.CabinetNameTemplate = "Cab{0}.cab"; | 23 | this.CabinetNameTemplate = "Cab{0}.cab"; |
| 24 | this.Section = section; | 24 | this.Section = section; |
| @@ -31,7 +31,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 31 | 31 | ||
| 32 | private IMessaging Messaging { get; } | 32 | private IMessaging Messaging { get; } |
| 33 | 33 | ||
| 34 | private IEnumerable<FileFacade> FileFacades { get; } | 34 | private IEnumerable<IFileFacade> FileFacades { get; } |
| 35 | 35 | ||
| 36 | private bool FilesCompressed { get; } | 36 | private bool FilesCompressed { get; } |
| 37 | 37 | ||
| @@ -40,13 +40,13 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 40 | /// <summary> | 40 | /// <summary> |
| 41 | /// Gets cabinets with their file rows. | 41 | /// Gets cabinets with their file rows. |
| 42 | /// </summary> | 42 | /// </summary> |
| 43 | public Dictionary<MediaSymbol, IEnumerable<FileFacade>> FileFacadesByCabinetMedia { get; private set; } | 43 | public Dictionary<MediaSymbol, IEnumerable<IFileFacade>> FileFacadesByCabinetMedia { get; private set; } |
| 44 | 44 | ||
| 45 | /// <summary> | 45 | /// <summary> |
| 46 | /// Get uncompressed file rows. This will contain file rows of File elements that are marked with compression=no. | 46 | /// Get uncompressed file rows. This will contain file rows of File elements that are marked with compression=no. |
| 47 | /// This contains all the files when Package element is marked with compression=no | 47 | /// This contains all the files when Package element is marked with compression=no |
| 48 | /// </summary> | 48 | /// </summary> |
| 49 | public IEnumerable<FileFacade> UncompressedFileFacades { get; private set; } | 49 | public IEnumerable<IFileFacade> UncompressedFileFacades { get; private set; } |
| 50 | 50 | ||
| 51 | public void Execute() | 51 | public void Execute() |
| 52 | { | 52 | { |
| @@ -79,34 +79,34 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 79 | Cabinet = "#MergeModule.CABinet", | 79 | Cabinet = "#MergeModule.CABinet", |
| 80 | }); | 80 | }); |
| 81 | 81 | ||
| 82 | this.FileFacadesByCabinetMedia = new Dictionary<MediaSymbol, IEnumerable<FileFacade>> | 82 | this.FileFacadesByCabinetMedia = new Dictionary<MediaSymbol, IEnumerable<IFileFacade>> |
| 83 | { | 83 | { |
| 84 | { mergeModuleMediaSymbol, this.FileFacades } | 84 | { mergeModuleMediaSymbol, this.FileFacades } |
| 85 | }; | 85 | }; |
| 86 | 86 | ||
| 87 | this.UncompressedFileFacades = Array.Empty<FileFacade>(); | 87 | this.UncompressedFileFacades = Array.Empty<IFileFacade>(); |
| 88 | } | 88 | } |
| 89 | else if (mediaTemplateSymbols.Count == 0) | 89 | else if (mediaTemplateSymbols.Count == 0) |
| 90 | { | 90 | { |
| 91 | var filesByCabinetMedia = new Dictionary<MediaSymbol, List<FileFacade>>(); | 91 | var filesByCabinetMedia = new Dictionary<MediaSymbol, List<IFileFacade>>(); |
| 92 | 92 | ||
| 93 | var uncompressedFiles = new List<FileFacade>(); | 93 | var uncompressedFiles = new List<IFileFacade>(); |
| 94 | 94 | ||
| 95 | this.ManuallyAssignFiles(mediaSymbols, filesByCabinetMedia, uncompressedFiles); | 95 | this.ManuallyAssignFiles(mediaSymbols, filesByCabinetMedia, uncompressedFiles); |
| 96 | 96 | ||
| 97 | this.FileFacadesByCabinetMedia = filesByCabinetMedia.ToDictionary(kvp => kvp.Key, kvp => (IEnumerable<FileFacade>)kvp.Value); | 97 | this.FileFacadesByCabinetMedia = filesByCabinetMedia.ToDictionary(kvp => kvp.Key, kvp => (IEnumerable<IFileFacade>)kvp.Value); |
| 98 | 98 | ||
| 99 | this.UncompressedFileFacades = uncompressedFiles; | 99 | this.UncompressedFileFacades = uncompressedFiles; |
| 100 | } | 100 | } |
| 101 | else | 101 | else |
| 102 | { | 102 | { |
| 103 | var filesByCabinetMedia = new Dictionary<MediaSymbol, List<FileFacade>>(); | 103 | var filesByCabinetMedia = new Dictionary<MediaSymbol, List<IFileFacade>>(); |
| 104 | 104 | ||
| 105 | var uncompressedFiles = new List<FileFacade>(); | 105 | var uncompressedFiles = new List<IFileFacade>(); |
| 106 | 106 | ||
| 107 | this.AutoAssignFiles(mediaSymbols, filesByCabinetMedia, uncompressedFiles); | 107 | this.AutoAssignFiles(mediaSymbols, filesByCabinetMedia, uncompressedFiles); |
| 108 | 108 | ||
| 109 | this.FileFacadesByCabinetMedia = filesByCabinetMedia.ToDictionary(kvp => kvp.Key, kvp => (IEnumerable<FileFacade>)kvp.Value); | 109 | this.FileFacadesByCabinetMedia = filesByCabinetMedia.ToDictionary(kvp => kvp.Key, kvp => (IEnumerable<IFileFacade>)kvp.Value); |
| 110 | 110 | ||
| 111 | this.UncompressedFileFacades = uncompressedFiles; | 111 | this.UncompressedFileFacades = uncompressedFiles; |
| 112 | } | 112 | } |
| @@ -115,7 +115,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 115 | /// <summary> | 115 | /// <summary> |
| 116 | /// Assign files to cabinets based on MediaTemplate authoring. | 116 | /// Assign files to cabinets based on MediaTemplate authoring. |
| 117 | /// </summary> | 117 | /// </summary> |
| 118 | private void AutoAssignFiles(List<MediaSymbol> mediaTable, Dictionary<MediaSymbol, List<FileFacade>> filesByCabinetMedia, List<FileFacade> uncompressedFiles) | 118 | private void AutoAssignFiles(List<MediaSymbol> mediaTable, Dictionary<MediaSymbol, List<IFileFacade>> filesByCabinetMedia, List<IFileFacade> uncompressedFiles) |
| 119 | { | 119 | { |
| 120 | const int MaxCabIndex = 999; | 120 | const int MaxCabIndex = 999; |
| 121 | 121 | ||
| @@ -194,7 +194,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 194 | { | 194 | { |
| 195 | currentMediaRow = this.AddMediaSymbol(mediaTemplateRow, ++currentCabIndex); | 195 | currentMediaRow = this.AddMediaSymbol(mediaTemplateRow, ++currentCabIndex); |
| 196 | mediaSymbolsByDiskId.Add(currentMediaRow.DiskId, currentMediaRow); | 196 | mediaSymbolsByDiskId.Add(currentMediaRow.DiskId, currentMediaRow); |
| 197 | filesByCabinetMedia.Add(currentMediaRow, new List<FileFacade>()); | 197 | filesByCabinetMedia.Add(currentMediaRow, new List<IFileFacade>()); |
| 198 | 198 | ||
| 199 | // Now files larger than MaxUncompressedMediaSize will be the only file in its cabinet so as to respect MaxUncompressedMediaSize | 199 | // Now files larger than MaxUncompressedMediaSize will be the only file in its cabinet so as to respect MaxUncompressedMediaSize |
| 200 | currentPreCabSize = (ulong)facade.FileSize; | 200 | currentPreCabSize = (ulong)facade.FileSize; |
| @@ -206,7 +206,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 206 | // Create new cab and MediaRow | 206 | // Create new cab and MediaRow |
| 207 | currentMediaRow = this.AddMediaSymbol(mediaTemplateRow, ++currentCabIndex); | 207 | currentMediaRow = this.AddMediaSymbol(mediaTemplateRow, ++currentCabIndex); |
| 208 | mediaSymbolsByDiskId.Add(currentMediaRow.DiskId, currentMediaRow); | 208 | mediaSymbolsByDiskId.Add(currentMediaRow.DiskId, currentMediaRow); |
| 209 | filesByCabinetMedia.Add(currentMediaRow, new List<FileFacade>()); | 209 | filesByCabinetMedia.Add(currentMediaRow, new List<IFileFacade>()); |
| 210 | } | 210 | } |
| 211 | } | 211 | } |
| 212 | } | 212 | } |
| @@ -232,7 +232,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 232 | /// <summary> | 232 | /// <summary> |
| 233 | /// Assign files to cabinets based on Media authoring. | 233 | /// Assign files to cabinets based on Media authoring. |
| 234 | /// </summary> | 234 | /// </summary> |
| 235 | private void ManuallyAssignFiles(List<MediaSymbol> mediaSymbols, Dictionary<MediaSymbol, List<FileFacade>> filesByCabinetMedia, List<FileFacade> uncompressedFiles) | 235 | private void ManuallyAssignFiles(List<MediaSymbol> mediaSymbols, Dictionary<MediaSymbol, List<IFileFacade>> filesByCabinetMedia, List<IFileFacade> uncompressedFiles) |
| 236 | { | 236 | { |
| 237 | var mediaSymbolsByDiskId = new Dictionary<int, MediaSymbol>(); | 237 | var mediaSymbolsByDiskId = new Dictionary<int, MediaSymbol>(); |
| 238 | 238 | ||
| @@ -254,7 +254,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 254 | cabinetMediaSymbols.Add(mediaSymbol.Cabinet, mediaSymbol); | 254 | cabinetMediaSymbols.Add(mediaSymbol.Cabinet, mediaSymbol); |
| 255 | } | 255 | } |
| 256 | 256 | ||
| 257 | filesByCabinetMedia.Add(mediaSymbol, new List<FileFacade>()); | 257 | filesByCabinetMedia.Add(mediaSymbol, new List<IFileFacade>()); |
| 258 | } | 258 | } |
| 259 | 259 | ||
| 260 | mediaSymbolsByDiskId.Add(mediaSymbol.DiskId, mediaSymbol); | 260 | mediaSymbolsByDiskId.Add(mediaSymbol.DiskId, mediaSymbol); |
