forked from microsoft/winget-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSourceInstaller.cs
More file actions
40 lines (36 loc) · 1.37 KB
/
Copy pathSourceInstaller.cs
File metadata and controls
40 lines (36 loc) · 1.37 KB
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
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
namespace WinGetSourceCreator.Model
{
public class SourceInstaller : Installer
{
public SourceInstaller(string workingDirectory, DynamicInstaller installer)
{
this.Initialize(installer);
this.InstallerFile = installer.Create(workingDirectory);
}
public SourceInstaller(string workingDirectory, LocalInstaller installer)
{
this.Initialize(installer);
this.InstallerFile = Path.Combine(workingDirectory, this.Name);
var parent = Path.GetDirectoryName(this.InstallerFile);
if (!string.IsNullOrEmpty(parent))
{
Directory.CreateDirectory(parent);
}
File.Copy(installer.Input, this.InstallerFile, true);
}
public string InstallerFile { get; private set; }
private void Initialize(Installer installer)
{
foreach (var installerProperty in installer.GetType().GetProperties())
{
var toProperty = this.GetType().GetProperty(installerProperty.Name);
if (toProperty != null)
{
toProperty.SetValue(this, installerProperty.GetValue(installer));
}
}
}
}
}