Esempio n. 1
0
        /// <summary>
        /// Restores the state to before the installation.
        /// </summary>
        /// <param name="state">The installer state.</param>
        private void Restore(IDictionary state)
        {
            string uriPrefix = (string)state[InstallTools.GetStateKey(this, "UriPrefix")];
            string account   = (string)state[InstallTools.GetStateKey(this, "Account")];

            HttpSys.RemovePrefixReservation(uriPrefix, account);
        }
Esempio n. 2
0
        /// <summary>
        /// Restores the state to before the installation.
        /// </summary>
        /// <param name="state">The installer state.</param>
        private void Restore(IDictionary state)
        {
            try
            {
                string keyPath  = (string)state[InstallTools.GetStateKey(this, "KeyPath")];
                object orgValue = state[InstallTools.GetStateKey(this, "OrgValue")];

                if (orgValue == null)
                {
                    RegKey.Delete(keyPath);
                }
                else if (orgValue is int)
                {
                    RegKey.SetValue(keyPath, (int)orgValue);
                }
                else if (orgValue is string)
                {
                    RegKey.GetValue(keyPath, (string)orgValue);
                }
                else
                {
                    throw new InvalidOperationException("RegInstaller works only for REG_DWORD and REG_SZ registry values.");
                }
            }
            catch
            {
                // I'm going to ignore errors here since it'll often be the case
                // that the parent key has already been removed.
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Installs the registry key.
        /// </summary>
        /// <param name="state">The installer state.</param>
        public override void Install(IDictionary state)
        {
            base.Install(state);

            state[InstallTools.GetStateKey(this, "UriPrefix")] = uriPrefix;
            state[InstallTools.GetStateKey(this, "Account")]   = account;

            HttpSys.AddPrefixReservation(uriPrefix, account);
        }
Esempio n. 4
0
        /// <summary>
        /// Installs the registry key.
        /// </summary>
        /// <param name="state">The installer state.</param>
        public override void Install(IDictionary state)
        {
            object orgValue;

            base.Install(state);

            switch (RegKey.GetValueType(keyPath))
            {
            case WinApi.REG_NONE:

                orgValue = null;
                break;

            case WinApi.REG_DWORD:

                orgValue = RegKey.GetValue(keyPath, 0);
                break;

            case WinApi.REG_SZ:

                orgValue = RegKey.GetValue(keyPath, string.Empty);
                break;

            default:

                throw new InvalidOperationException("RegInstaller works only for REG_DWORD and REG_SZ registry values.");
            }

            state[InstallTools.GetStateKey(this, "KeyPath")]  = keyPath;
            state[InstallTools.GetStateKey(this, "OrgValue")] = orgValue;

            if (strValue != null)
            {
                RegKey.SetValue(keyPath, strValue);
            }
            else
            {
                RegKey.SetValue(keyPath, intValue);
            }
        }