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
|
// 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.Databases
{
using System;
using System.Collections;
using System.Globalization;
using WixToolset.MergeMod;
/// <summary>
/// Callback object for configurable merge modules.
/// </summary>
internal sealed class ConfigurationCallback : IMsmConfigureModule
{
private const int SOk = 0x0;
private const int SFalse = 0x1;
private Hashtable configurationData;
/// <summary>
/// Creates a ConfigurationCallback object.
/// </summary>
/// <param name="configData">String to break up into name/value pairs.</param>
public ConfigurationCallback(string configData)
{
if (String.IsNullOrEmpty(configData))
{
throw new ArgumentNullException("configData");
}
string[] pairs = configData.Split(',');
this.configurationData = new Hashtable(pairs.Length);
for (int i = 0; i < pairs.Length; ++i)
{
string[] nameVal = pairs[i].Split('=');
string name = nameVal[0];
string value = nameVal[1];
name = name.Replace("%2C", ",");
name = name.Replace("%3D", "=");
name = name.Replace("%25", "%");
value = value.Replace("%2C", ",");
value = value.Replace("%3D", "=");
value = value.Replace("%25", "%");
this.configurationData[name] = value;
}
}
/// <summary>
/// Returns text data based on name.
/// </summary>
/// <param name="name">Name of value to return.</param>
/// <param name="configData">Out param to put configuration data into.</param>
/// <returns>S_OK if value provided, S_FALSE if not.</returns>
public int ProvideTextData(string name, out string configData)
{
if (this.configurationData.Contains(name))
{
configData = (string)this.configurationData[name];
return SOk;
}
else
{
configData = null;
return SFalse;
}
}
/// <summary>
/// Returns integer data based on name.
/// </summary>
/// <param name="name">Name of value to return.</param>
/// <param name="configData">Out param to put configuration data into.</param>
/// <returns>S_OK if value provided, S_FALSE if not.</returns>
public int ProvideIntegerData(string name, out int configData)
{
if (this.configurationData.Contains(name))
{
string val = (string)this.configurationData[name];
configData = Convert.ToInt32(val, CultureInfo.InvariantCulture);
return SOk;
}
else
{
configData = 0;
return SFalse;
}
}
}
}
|