main
cs 73 lines 2.53 KB
Raw
1 // 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.
2
3 namespace WixToolset.Core.WindowsInstaller.Bind
4 {
5 using System.Collections.Generic;
6 using System.Linq;
7 using WixToolset.Data;
8 using WixToolset.Data.Symbols;
9 using WixToolset.Extensibility.Data;
10 using WixToolset.Extensibility.Services;
11
12 internal class UpdateSymbolsWithFileFacadesCommand
13 {
14 private readonly IntermediateSection section;
15 private readonly List<IFileFacade> allFileFacades;
16
17 public UpdateSymbolsWithFileFacadesCommand(IntermediateSection section, List<IFileFacade> allFileFacades)
18 {
19 this.section = section;
20 this.allFileFacades = allFileFacades;
21 }
22
23 public void Execute()
24 {
25 var fileSymbolsById = this.section.Symbols.OfType<FileSymbol>().ToDictionary(f => f.Id.Id);
26
27 foreach (var facade in this.allFileFacades)
28 {
29 if (fileSymbolsById.TryGetValue(facade.Id, out var fileSymbol))
30 {
31 // Only update the file symbol if the facade value changed
32 if (fileSymbol.DiskId != facade.DiskId)
33 {
34 fileSymbol.DiskId = facade.DiskId;
35 }
36
37 if (fileSymbol.FileSize != facade.FileSize)
38 {
39 fileSymbol.FileSize = facade.FileSize;
40 }
41
42 if (fileSymbol.Language != facade.Language)
43 {
44 fileSymbol.Language = facade.Language;
45 }
46
47 if (fileSymbol.Sequence != facade.Sequence)
48 {
49 fileSymbol.Sequence = facade.Sequence;
50 }
51
52 if (fileSymbol.Version != facade.Version)
53 {
54 fileSymbol.Version = facade.Version;
55 }
56 }
57
58 if (facade.MsiFileHashSymbol != null)
59 {
60 this.section.AddSymbol(facade.MsiFileHashSymbol);
61 }
62
63 if (facade.AssemblyNameSymbols != null)
64 {
65 foreach (var assemblyNameSymbol in facade.AssemblyNameSymbols)
66 {
67 this.section.AddSymbol(assemblyNameSymbol);
68 }
69 }
70 }
71 }
72 }
73 }