blob: 9f03e95b8a224be4ac84cfce725b9d8032dc32a9 (
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
|
// 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.UX
{
using System;
using System.Collections.Generic;
using System.Net;
using WixToolset.Bootstrapper;
/// <summary>
/// The model.
/// </summary>
public class Model
{
private const string BurnBundleInstallDirectoryVariable = "InstallFolder";
private const string BurnBundleLayoutDirectoryVariable = "WixBundleLayoutDirectory";
private const string BurnBundleVersionVariable = "WixBundleVersion";
/// <summary>
/// Creates a new model for the UX.
/// </summary>
/// <param name="bootstrapper">Bootstrapper hosting the UX.</param>
public Model(BootstrapperApplication bootstrapper)
{
this.Bootstrapper = bootstrapper;
this.Telemetry = new List<KeyValuePair<string, string>>();
this.Version = this.Engine.VersionVariables[BurnBundleVersionVariable];
}
/// <summary>
/// Gets the bootstrapper.
/// </summary>
public BootstrapperApplication Bootstrapper { get; private set; }
/// <summary>
/// Gets the bootstrapper command-line.
/// </summary>
public Command Command { get { return this.Bootstrapper.Command; } }
/// <summary>
/// Gets the bootstrapper engine.
/// </summary>
public Engine Engine { get { return this.Bootstrapper.Engine; } }
/// <summary>
/// Gets the key/value pairs used in telemetry.
/// </summary>
public List<KeyValuePair<string, string>> Telemetry { get; private set; }
/// <summary>
/// Get or set the final result of the installation.
/// </summary>
public int Result { get; set; }
/// <summary>
/// Get the version of the install.
/// </summary>
public Version Version { get; private set; }
/// <summary>
/// Get or set the path where the bundle is installed.
/// </summary>
public string InstallDirectory
{
get
{
if (!this.Engine.StringVariables.Contains(BurnBundleInstallDirectoryVariable))
{
return null;
}
return this.Engine.StringVariables[BurnBundleInstallDirectoryVariable];
}
set
{
this.Engine.StringVariables[BurnBundleInstallDirectoryVariable] = value;
}
}
/// <summary>
/// Get or set the path for the layout to be created.
/// </summary>
public string LayoutDirectory
{
get
{
if (!this.Engine.StringVariables.Contains(BurnBundleLayoutDirectoryVariable))
{
return null;
}
return this.Engine.StringVariables[BurnBundleLayoutDirectoryVariable];
}
set
{
this.Engine.StringVariables[BurnBundleLayoutDirectoryVariable] = value;
}
}
public LaunchAction PlannedAction { get; set; }
/// <summary>
/// Creates a correctly configured HTTP web request.
/// </summary>
/// <param name="uri">URI to connect to.</param>
/// <returns>Correctly configured HTTP web request.</returns>
public HttpWebRequest CreateWebRequest(string uri)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.UserAgent = String.Concat("WixInstall", this.Version.ToString());
return request;
}
/// <summary>
/// Gets the display name for a package if possible.
/// </summary>
/// <param name="packageId">Identity of the package to find the display name.</param>
/// <returns>Display name of the package if found or the package id if not.</returns>
public string GetPackageName(string packageId)
{
PackageInfo package;
return this.Bootstrapper.BAManifest.Bundle.Packages.TryGetValue(packageId, out package) ? package.DisplayName : packageId;
}
}
}
|