@joebigelow / wix-1 / commits / 167d26d0

Normalize commands to use constructors

Rob Mensching committed Jun 12, 2020 at 12:51 UTC 167d26d002b1412e72d96ed2bbc0761fc0f1344b
3 files changed +52 -52
src/WixToolset.Core.WindowsInstaller/Bind/AssignMediaCommand.cs
+5 -3
@@ -18,20 +18,22 @@ namespace WixToolset.Core.WindowsInstaller.Bind
18 {
19 private const int DefaultMaximumUncompressedMediaSize = 200; // Default value is 200 MB
20
21 - public AssignMediaCommand(IntermediateSection section, IMessaging messaging)
21 + public AssignMediaCommand(IntermediateSection section, IMessaging messaging, IEnumerable<FileFacade> fileFacades, bool compressed)
22 {
23 this.CabinetNameTemplate = "Cab{0}.cab";
24 this.Section = section;
25 this.Messaging = messaging;
26 + this.FileFacades = fileFacades;
27 + this.FilesCompressed = compressed;
28 }
29
30 private IntermediateSection Section { get; }
31
32 private IMessaging Messaging { get; }
33
32 - public IEnumerable<FileFacade> FileFacades { private get; set; }
34 + private IEnumerable<FileFacade> FileFacades { get; }
35
34 - public bool FilesCompressed { private get; set; }
36 + private bool FilesCompressed { get; }
37
38 public string CabinetNameTemplate { private get; set; }
39
src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs
+38 -44
@@ -277,11 +277,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
277
278 // Gather information about files that do not come from merge modules.
279 {
280 - var command = new UpdateFileFacadesCommand(this.Messaging, section);
281 - command.FileFacades = fileFacades;
282 - command.UpdateFileFacades = fileFacades.Where(f => !f.FromModule);
283 - command.OverwriteHash = true;
284 - command.VariableCache = variableCache;
280 + var command = new UpdateFileFacadesCommand(this.Messaging, section, fileFacades, fileFacades.Where(f => !f.FromModule), variableCache, overwriteHash: true);
281 command.Execute();
282 }
283
@@ -290,9 +286,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
286 Dictionary<MediaTuple, IEnumerable<FileFacade>> filesByCabinetMedia;
287 IEnumerable<FileFacade> uncompressedFiles;
288 {
293 - var command = new AssignMediaCommand(section, this.Messaging);
294 - command.FileFacades = fileFacades;
295 - command.FilesCompressed = compressed;
289 + var command = new AssignMediaCommand(section, this.Messaging, fileFacades, compressed);
290 command.Execute();
291
292 assignedMediaRows = command.MediaRows;
@@ -313,6 +307,42 @@ namespace WixToolset.Core.WindowsInstaller.Bind
307 command.Execute();
308 }
309
310 +#if TODO_FINISH_UPDATE // use tuples instead of rows
311 + // Extended binder extensions can be called now that fields are resolved.
312 + {
313 + Table updatedFiles = this.Output.EnsureTable(this.TableDefinitions["WixBindUpdatedFiles"]);
314 +
315 + foreach (IBinderExtension extension in this.Extensions)
316 + {
317 + extension.AfterResolvedFields(this.Output);
318 + }
319 +
320 + List<FileFacade> updatedFileFacades = new List<FileFacade>();
321 +
322 + foreach (Row updatedFile in updatedFiles.Rows)
323 + {
324 + string updatedId = updatedFile.FieldAsString(0);
325 +
326 + FileFacade updatedFacade = fileFacades.First(f => f.File.File.Equals(updatedId));
327 +
328 + updatedFileFacades.Add(updatedFacade);
329 + }
330 +
331 + if (updatedFileFacades.Any())
332 + {
333 + UpdateFileFacadesCommand command = new UpdateFileFacadesCommand(this.Messaging, section, fileFacades, updateFileFacades, variableCache, overwriteHash: false);
334 + //command.FileFacades = fileFacades;
335 + //command.UpdateFileFacades = updatedFileFacades;
336 + //command.ModularizationGuid = modularizationGuid;
337 + //command.Output = this.Output;
338 + //command.OverwriteHash = true;
339 + //command.TableDefinitions = this.TableDefinitions;
340 + //command.VariableCache = variableCache;
341 + command.Execute();
342 + }
343 + }
344 +#endif
345 +
346 // Set generated component guids.
347 {
348 var command = new CalculateComponentGuids(this.Messaging, this.BackendHelper, this.PathResolver, section);
@@ -376,42 +406,6 @@ namespace WixToolset.Core.WindowsInstaller.Bind
406 }
407 }
408
379 -#if TODO_FINISH_UPDATE
380 - // Extended binder extensions can be called now that fields are resolved.
381 - {
382 - Table updatedFiles = this.Output.EnsureTable(this.TableDefinitions["WixBindUpdatedFiles"]);
383 -
384 - foreach (IBinderExtension extension in this.Extensions)
385 - {
386 - extension.AfterResolvedFields(this.Output);
387 - }
388 -
389 - List<FileFacade> updatedFileFacades = new List<FileFacade>();
390 -
391 - foreach (Row updatedFile in updatedFiles.Rows)
392 - {
393 - string updatedId = updatedFile.FieldAsString(0);
394 -
395 - FileFacade updatedFacade = fileFacades.First(f => f.File.File.Equals(updatedId));
396 -
397 - updatedFileFacades.Add(updatedFacade);
398 - }
399 -
400 - if (updatedFileFacades.Any())
401 - {
402 - UpdateFileFacadesCommand command = new UpdateFileFacadesCommand();
403 - command.FileFacades = fileFacades;
404 - command.UpdateFileFacades = updatedFileFacades;
405 - command.ModularizationGuid = modularizationGuid;
406 - command.Output = this.Output;
407 - command.OverwriteHash = true;
408 - command.TableDefinitions = this.TableDefinitions;
409 - command.VariableCache = variableCache;
410 - command.Execute();
411 - }
412 - }
413 -#endif
414 -
409 // Stop processing if an error previously occurred.
410 if (this.Messaging.EncounteredError)
411 {
src/WixToolset.Core.WindowsInstaller/Bind/UpdateFileFacadesCommand.cs
+9 -5
@@ -19,23 +19,27 @@ namespace WixToolset.Core.WindowsInstaller.Bind
19 /// </summary>
20 internal class UpdateFileFacadesCommand
21 {
22 - public UpdateFileFacadesCommand(IMessaging messaging, IntermediateSection section)
22 + public UpdateFileFacadesCommand(IMessaging messaging, IntermediateSection section, IEnumerable<FileFacade> fileFacades, IEnumerable<FileFacade> updateFileFacades, IDictionary<string, string> variableCache, bool overwriteHash)
23 {
24 this.Messaging = messaging;
25 this.Section = section;
26 + this.FileFacades = fileFacades;
27 + this.UpdateFileFacades = updateFileFacades;
28 + this.VariableCache = variableCache;
29 + this.OverwriteHash = overwriteHash;
30 }
31
32 private IMessaging Messaging { get; }
33
34 private IntermediateSection Section { get; }
35
32 - public IEnumerable<FileFacade> FileFacades { private get; set; }
36 + private IEnumerable<FileFacade> FileFacades { get; }
37
34 - public IEnumerable<FileFacade> UpdateFileFacades { private get; set; }
38 + private IEnumerable<FileFacade> UpdateFileFacades { get; }
39
36 - public bool OverwriteHash { private get; set; }
40 + private bool OverwriteHash { get; }
41
38 - public IDictionary<string, string> VariableCache { private get; set; }
42 + private IDictionary<string, string> VariableCache { get; }
43
44 public void Execute()
45 {