blob: cfe902720275bb22b32892741be67ac4589b0faa (
plain)
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
|
// 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.Harvesters
{
using System;
using System.Collections;
using System.Collections.Specialized;
using WixToolset.Harvesters.Data;
using WixToolset.Harvesters.Extensibility;
using Wix = WixToolset.Harvesters.Serialize;
using IIs = Serialize.IIs;
/// <summary>
/// The finalize harvester mutator for the WiX Toolset Internet Information Services Extension.
/// </summary>
public sealed class IIsFinalizeHarvesterMutator : BaseMutatorExtension
{
private Hashtable directoryPaths;
private Hashtable filePaths;
private ArrayList webFilters;
private ArrayList webSites;
private ArrayList webVirtualDirs;
/// <summary>
/// Instantiate a new IIsFinalizeHarvesterMutator.
/// </summary>
public IIsFinalizeHarvesterMutator()
{
this.directoryPaths = CollectionsUtil.CreateCaseInsensitiveHashtable();
this.filePaths = CollectionsUtil.CreateCaseInsensitiveHashtable();
this.webFilters = new ArrayList();
this.webSites = new ArrayList();
this.webVirtualDirs = new ArrayList();
}
/// <summary>
/// Gets the sequence of this mutator extension.
/// </summary>
/// <value>The sequence of this mutator extension.</value>
public override int Sequence
{
get { return 1900; }
}
/// <summary>
/// Mutate a WiX document.
/// </summary>
/// <param name="wix">The Wix document element.</param>
public override void Mutate(Wix.Wix wix)
{
this.directoryPaths.Clear();
this.filePaths.Clear();
this.webFilters.Clear();
this.webSites.Clear();
this.webVirtualDirs.Clear();
this.IndexElement(wix);
this.MutateWebFilters();
this.MutateWebSites();
this.MutateWebVirtualDirs();
}
/// <summary>
/// Index an element.
/// </summary>
/// <param name="element">The element to index.</param>
private void IndexElement(Wix.ISchemaElement element)
{
if (element is IIs.WebFilter)
{
this.webFilters.Add(element);
}
else if (element is IIs.WebSite)
{
this.webSites.Add(element);
}
else if (element is IIs.WebVirtualDir)
{
this.webVirtualDirs.Add(element);
}
else if (element is Wix.Directory)
{
Wix.Directory directory = (Wix.Directory)element;
if (null != directory.Id && null != directory.FileSource)
{
this.directoryPaths.Add(directory.FileSource, directory.Id);
}
}
else if (element is Wix.File)
{
Wix.File file = (Wix.File)element;
if (null != file.Id && null != file.Source)
{
this.filePaths[file.Source] = String.Concat("[#", file.Id, "]");
}
}
// index the child elements
if (element is Wix.IParentElement)
{
foreach (Wix.ISchemaElement childElement in ((Wix.IParentElement)element).Children)
{
this.IndexElement(childElement);
}
}
}
/// <summary>
/// Mutate the WebFilters.
/// </summary>
private void MutateWebFilters()
{
foreach (IIs.WebFilter webFilter in this.webFilters)
{
webFilter.Path = (string)this.filePaths[webFilter.Path];
}
}
/// <summary>
/// Mutate the WebSites.
/// </summary>
private void MutateWebSites()
{
foreach (IIs.WebSite webSite in this.webSites)
{
string path = (string)this.directoryPaths[webSite.Directory];
if (null == path)
{
this.Core.Messaging.Write(HarvesterWarnings.EncounteredNullDirectoryForWebSite(path));
}
else
{
webSite.Directory = path;
}
}
}
/// <summary>
/// Mutate the WebVirtualDirs.
/// </summary>
private void MutateWebVirtualDirs()
{
foreach (IIs.WebVirtualDir webVirtualDir in this.webVirtualDirs)
{
string path = (string)this.directoryPaths[webVirtualDir.Directory];
if (null == path)
{
this.Core.Messaging.Write(HarvesterWarnings.EncounteredNullDirectoryForWebSite(path));
}
else
{
webVirtualDir.Directory = path;
}
}
}
}
}
|