1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
// 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
{
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using WixToolset.Core.Bind;
using WixToolset.Data;
using WixToolset.Data.Tuples;
internal class GetFileFacadesCommand
{
public GetFileFacadesCommand(IntermediateSection section)
{
this.Section = section;
}
private IntermediateSection Section { get; }
public List<FileFacade> FileFacades { get; private set; }
public void Execute()
{
var facades = new List<FileFacade>();
var wixFiles = this.Section.Tuples.OfType<WixFileTuple>().ToDictionary(t => t.File_);
var deltaPatchFiles = this.Section.Tuples.OfType<WixDeltaPatchFileTuple>().ToDictionary(t => t.File_);
foreach (var file in this.Section.Tuples.OfType<FileTuple>())
{
var wixFile = wixFiles[file.File];
deltaPatchFiles.TryGetValue(file.File, out var deltaPatchFile);
facades.Add(new FileFacade(file, wixFile, deltaPatchFile));
}
this.ResolveDeltaPatchSymbolPaths(deltaPatchFiles, facades);
this.FileFacades = facades;
}
/// <summary>
/// Merge data from the WixPatchSymbolPaths rows into the WixDeltaPatchFile rows.
/// </summary>
public void ResolveDeltaPatchSymbolPaths(Dictionary<string, WixDeltaPatchFileTuple> deltaPatchFiles, IEnumerable<FileFacade> facades)
{
ILookup<string, FileFacade> filesByComponent = null;
ILookup<string, FileFacade> filesByDirectory = null;
ILookup<string, FileFacade> filesByDiskId = null;
foreach (var row in this.Section.Tuples.OfType<WixDeltaPatchSymbolPathsTuple>().OrderBy(r => r.Type))
{
switch (row.Type)
{
case SymbolPathType.File:
this.MergeSymbolPaths(row, deltaPatchFiles[row.Id]);
break;
case SymbolPathType.Component:
if (null == filesByComponent)
{
filesByComponent = facades.ToLookup(f => f.File.Component_);
}
foreach (var facade in filesByComponent[row.Id])
{
this.MergeSymbolPaths(row, deltaPatchFiles[facade.File.File]);
}
break;
case SymbolPathType.Directory:
if (null == filesByDirectory)
{
filesByDirectory = facades.ToLookup(f => f.WixFile.Directory_);
}
foreach (var facade in filesByDirectory[row.Id])
{
this.MergeSymbolPaths(row, deltaPatchFiles[facade.File.File]);
}
break;
case SymbolPathType.Media:
if (null == filesByDiskId)
{
filesByDiskId = facades.ToLookup(f => f.WixFile.DiskId.ToString(CultureInfo.InvariantCulture));
}
foreach (var facade in filesByDiskId[row.Id])
{
this.MergeSymbolPaths(row, deltaPatchFiles[facade.File.File]);
}
break;
case SymbolPathType.Product:
foreach (var fileRow in deltaPatchFiles.Values)
{
this.MergeSymbolPaths(row, fileRow);
}
break;
default:
// error
break;
}
}
}
/// <summary>
/// Merge data from a row in the WixPatchSymbolsPaths table into an associated WixDeltaPatchFile row.
/// </summary>
/// <param name="row">Row from the WixPatchSymbolsPaths table.</param>
/// <param name="file">FileRow into which to set symbol information.</param>
/// <comment>This includes PreviousData as well.</comment>
private void MergeSymbolPaths(WixDeltaPatchSymbolPathsTuple row, WixDeltaPatchFileTuple file)
{
if (file.SymbolPaths is null)
{
file.SymbolPaths = row.SymbolPaths;
}
else
{
file.SymbolPaths = String.Concat(file.SymbolPaths, ";", row.SymbolPaths);
}
#if REVISIT_FOR_PATCHING
Field field = row.Fields[2];
if (null != field.PreviousData)
{
if (null == file.PreviousSymbols)
{
file.PreviousSymbols = field.PreviousData;
}
else
{
file.PreviousSymbols = String.Concat(file.PreviousSymbols, ";", field.PreviousData);
}
}
#endif
}
}
}
|