コード例 #1
0
        /// <summary>
        /// Emits WiX Registry Values from the installation data.
        /// </summary>
        private int ConvertRegistryValues(DirectoryRef directory, ComponentGroup componentgroup, InstallationDataXml dataxml, IDictionary <string, string> macros)
        {
            foreach (RegistryValueXml valuexml in dataxml.Registry.Value)
            {
                try
                {
                    var value = new RegistryValue();
                    GetComponentForHive(valuexml.Hive, directory, componentgroup).AddChild(value);
                    value.Root = GetRoot(valuexml.Hive);
                    value.Key  = LocalInstaller.SubstituteMacros(macros, valuexml.Key);
                    if (!string.IsNullOrEmpty(valuexml.Name))                    // The default value name must be Null not an empty string
                    {
                        value.Name = LocalInstaller.SubstituteMacros(macros, valuexml.Name);
                    }
                    value.Value = LocalInstaller.SubstituteMacros(macros, valuexml.Value);
                    value.Type  = GetValueType(valuexml.Type);

                    value.Action = RegistryValue.ActionType.write;
                }
                catch (Exception ex)
                {
                    throw new InvalidOperationException(string.Format("Failed to process the value {0}. {1}", valuexml, ex.Message), ex);
                }
            }

            return(dataxml.Registry.Value.Length);
        }
コード例 #2
0
        /// <summary>
        /// Emits WiX Registry Keys from the installation data.
        /// </summary>
        private int ConvertRegistryKeys(DirectoryRef directory, ComponentGroup componentgroup, InstallationDataXml dataxml, IDictionary <string, string> macros)
        {
            foreach (RegistryKeyXml keyxml in dataxml.Registry.Key)            // Keys
            {
                try
                {
                    var key = new RegistryKey();
                    GetComponentForHive(keyxml.Hive, directory, componentgroup).AddChild(key);
                    key.Root   = GetRoot(keyxml.Hive);
                    key.Key    = LocalInstaller.SubstituteMacros(macros, keyxml.Key);
                    key.Action = RegistryKey.ActionType.createAndRemoveOnUninstall;
                }
                catch (Exception ex)
                {
                    throw new InvalidOperationException(string.Format("Failed to process the key {0}. {1}", keyxml, ex.Message), ex);
                }
            }

            return(dataxml.Registry.Key.Length);
        }