File size: 2,474 Bytes
8c763fb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Management.Automation;
using System.Reflection;

namespace Microsoft.PowerShell
{
    /// <summary>
    /// EngineInstaller is a class for facilitating registry of necessary
    /// information for PowerShell engine.
    ///
    /// At install time, installation utilities (like InstallUtil.exe) will
    /// call install this engine assembly based on the implementation in
    /// this class.
    ///
    /// This class derives from base class PSInstaller. PSInstaller will
    /// handle the details about how information got written into registry.
    /// Here, the information about registry content is provided.
    /// </summary>
    [RunInstaller(true)]
    public sealed class EngineInstaller : PSInstaller
    {
        /// <summary>
        /// Constructor.
        /// </summary>
        public EngineInstaller()
            : base()
        {
        }

        /// <summary>
        /// </summary>
        internal sealed override string RegKey
        {
            get
            {
                return RegistryStrings.MonadEngineKey;
            }
        }

        private static string EngineVersion
        {
            get
            {
                return PSVersionInfo.FeatureVersionString;
            }
        }

        private Dictionary<string, object> _regValues = null;
        /// <summary>
        /// </summary>
        internal sealed override Dictionary<string, object> RegValues
        {
            get
            {
                if (_regValues == null)
                {
                    _regValues = new Dictionary<string, object>();
                    _regValues[RegistryStrings.MonadEngine_MonadVersion] = EngineVersion;
                    _regValues[RegistryStrings.MonadEngine_ApplicationBase] = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                    _regValues[RegistryStrings.MonadEngine_ConsoleHostAssemblyName] = Assembly.GetExecutingAssembly().FullName;
                    _regValues[RegistryStrings.MonadEngine_ConsoleHostModuleName] = Assembly.GetExecutingAssembly().Location;
                    _regValues[RegistryStrings.MonadEngine_RuntimeVersion] = Assembly.GetExecutingAssembly().ImageRuntimeVersion;
                }

                return _regValues;
            }
        }
    }
}