aboutsummaryrefslogtreecommitdiff
path: root/src/dtf/WixToolset.Dtf.WindowsInstaller/Installation.cs
blob: 47ca00a162b880f3230b7563c885acacc33c9a7e (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
// 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.Dtf.WindowsInstaller
{
    using System;
    using System.Text;
    using System.Globalization;

    /// <summary>
    /// Subclasses of this abstract class represent a unique instance of a
    /// registered product or patch installation.
    /// </summary>
    public abstract class Installation
    {
        private string installationCode;
        private string userSid;
        private UserContexts context;
        private SourceList sourceList;

        internal Installation(string installationCode, string userSid, UserContexts context)
        {
            if (context == UserContexts.Machine)
            {
                userSid = null;
            }
            this.installationCode = installationCode;
            this.userSid = userSid;
            this.context = context;
        }

        /// <summary>
        /// Gets the user security identifier (SID) under which this product or patch
        /// installation is available.
        /// </summary>
        public string UserSid
        {
            get
            {
                return this.userSid;
            }
        }

        /// <summary>
        /// Gets the user context of this product or patch installation.
        /// </summary>
        public UserContexts Context
        {
            get
            {
                return this.context;
            }
        }

        /// <summary>
        /// Gets the source list of this product or patch installation.
        /// </summary>
        public virtual SourceList SourceList
        {
            get
            {
                if (this.sourceList == null)
                {
                    this.sourceList = new SourceList(this);
                }
                return this.sourceList;
            }
        }

        /// <summary>
        /// Gets a value indicating whether this product or patch is installed on the current system.
        /// </summary>
        public abstract bool IsInstalled
        {
            get;
        }

        internal string InstallationCode
        {
            get
            {
                return this.installationCode;
            }
        }

        internal abstract int InstallationType
        {
            get;
        }

        /// <summary>
        /// Gets a property about the product or patch installation.
        /// </summary>
        /// <param name="propertyName">Name of the property being retrieved.</param>
        /// <returns></returns>
        public abstract string this[string propertyName]
        {
            get;
        }
    }
}