Example #1
0
 /// <summary>
 /// Add an ActionRow to the collection.
 /// </summary>
 /// <param name="actionRow">The ActionRow to add.</param>
 public void Add(WixActionRow actionRow)
 {
     this.Add(actionRow, false);
 }
Example #2
0
        /// <summary>
        /// Add an ActionRow to the collection.
        /// </summary>
        /// <param name="actionRow">The ActionRow to add.</param>
        /// <param name="overwrite">true to overwrite an existing ActionRow; false otherwise.</param>
        public void Add(WixActionRow actionRow, bool overwrite)
        {
            string key = GetKey(actionRow.SequenceTable, actionRow.Action);

            if (overwrite)
            {
                this.collection[key] = actionRow;
            }
            else
            {
                this.collection.Add(key, actionRow);
            }
        }
Example #3
0
        /// <summary>
        /// Applies the condition and sequence to a standard action element based on the action row data.
        /// </summary>
        /// <param name="actionRow">Action row data from the database.</param>
        /// <param name="actionElement">Element to be sequenced.</param>
        private void SequenceStandardAction(WixActionRow actionRow, Wix.ActionSequenceType actionElement)
        {
            if (null != actionRow.Condition)
            {
                actionElement.Content = actionRow.Condition;
            }

            if ((null != actionRow.Before || null != actionRow.After) && 0 == actionRow.Sequence)
            {
                this.core.OnMessage(WixWarnings.DecompiledStandardActionRelativelyScheduledInModule(actionRow.SourceLineNumbers, actionRow.SequenceTable.ToString(), actionRow.Action));
            }
            else if (0 < actionRow.Sequence)
            {
                actionElement.Sequence = actionRow.Sequence;
            }
        }
Example #4
0
        /// <summary>
        /// Applies the condition and relative sequence to an action element based on the action row data.
        /// </summary>
        /// <param name="actionRow">Action row data from the database.</param>
        /// <param name="actionElement">Element to be sequenced.</param>
        private static void SequenceRelativeAction(WixActionRow actionRow, Wix.ActionModuleSequenceType actionElement)
        {
            if (null != actionRow.Condition)
            {
                actionElement.Content = actionRow.Condition;
            }

            if (null != actionRow.Before)
            {
                actionElement.Before = actionRow.Before;
            }
            else if (null != actionRow.After)
            {
                actionElement.After = actionRow.After;
            }
            else if (0 < actionRow.Sequence)
            {
                actionElement.Sequence = actionRow.Sequence;
            }
        }
Example #5
0
        /// <summary>
        /// Creates an action element.
        /// </summary>
        /// <param name="actionRow">The action row from which the element should be created.</param>
        private void CreateActionElement(WixActionRow actionRow)
        {
            Wix.ISchemaElement actionElement = null;

            if (null != this.core.GetIndexedElement("CustomAction", actionRow.Action)) // custom action
            {
                Wix.Custom custom = new Wix.Custom();

                custom.Action = actionRow.Action;

                if (null != actionRow.Condition)
                {
                    custom.Content = actionRow.Condition;
                }

                switch (actionRow.Sequence)
                {
                    case (-4):
                        custom.OnExit = Wix.ExitType.suspend;
                        break;
                    case (-3):
                        custom.OnExit = Wix.ExitType.error;
                        break;
                    case (-2):
                        custom.OnExit = Wix.ExitType.cancel;
                        break;
                    case (-1):
                        custom.OnExit = Wix.ExitType.success;
                        break;
                    default:
                        if (null != actionRow.Before)
                        {
                            custom.Before = actionRow.Before;
                        }
                        else if (null != actionRow.After)
                        {
                            custom.After = actionRow.After;
                        }
                        else if (0 < actionRow.Sequence)
                        {
                            custom.Sequence = actionRow.Sequence;
                        }
                        break;
                }

                actionElement = custom;
            }
            else if (null != this.core.GetIndexedElement("Dialog", actionRow.Action)) // dialog
            {
                Wix.Show show = new Wix.Show();

                show.Dialog = actionRow.Action;

                if (null != actionRow.Condition)
                {
                    show.Content = actionRow.Condition;
                }

                switch (actionRow.Sequence)
                {
                    case (-4):
                        show.OnExit = Wix.ExitType.suspend;
                        break;
                    case (-3):
                        show.OnExit = Wix.ExitType.error;
                        break;
                    case (-2):
                        show.OnExit = Wix.ExitType.cancel;
                        break;
                    case (-1):
                        show.OnExit = Wix.ExitType.success;
                        break;
                    default:
                        if (null != actionRow.Before)
                        {
                            show.Before = actionRow.Before;
                        }
                        else if (null != actionRow.After)
                        {
                            show.After = actionRow.After;
                        }
                        else if (0 < actionRow.Sequence)
                        {
                            show.Sequence = actionRow.Sequence;
                        }
                        break;
                }

                actionElement = show;
            }
            else // possibly a standard action without suggested sequence information
            {
                actionElement = this.CreateStandardActionElement(actionRow);
            }

            // add the action element to the appropriate sequence element
            if (null != actionElement)
            {
                string sequenceTable = actionRow.SequenceTable.ToString();
                Wix.IParentElement sequenceElement = (Wix.IParentElement)this.sequenceElements[sequenceTable];

                if (null == sequenceElement)
                {
                    switch (actionRow.SequenceTable)
                    {
                        case SequenceTable.AdminExecuteSequence:
                            sequenceElement = new Wix.AdminExecuteSequence();
                            break;
                        case SequenceTable.AdminUISequence:
                            sequenceElement = new Wix.AdminUISequence();
                            break;
                        case SequenceTable.AdvtExecuteSequence:
                            sequenceElement = new Wix.AdvertiseExecuteSequence();
                            break;
                        case SequenceTable.InstallExecuteSequence:
                            sequenceElement = new Wix.InstallExecuteSequence();
                            break;
                        case SequenceTable.InstallUISequence:
                            sequenceElement = new Wix.InstallUISequence();
                            break;
                        default:
                            throw new InvalidOperationException(WixStrings.EXP_UnknowSequenceTable);
                    }

                    this.core.RootElement.AddChild((Wix.ISchemaElement)sequenceElement);
                    this.sequenceElements.Add(sequenceTable, sequenceElement);
                }

                try
                {
                    sequenceElement.AddChild(actionElement);
                }
                catch (System.ArgumentException) // action/dialog is not valid for this sequence
                {
                    this.core.OnMessage(WixWarnings.IllegalActionInSequence(actionRow.SourceLineNumbers, actionRow.SequenceTable.ToString(), actionRow.Action));
                }
            }
        }
Example #6
0
        /// <summary>
        /// Creates a standard action element.
        /// </summary>
        /// <param name="actionRow">The action row from which the element should be created.</param>
        /// <returns>The created element.</returns>
        private Wix.ISchemaElement CreateStandardActionElement(WixActionRow actionRow)
        {
            Wix.ActionSequenceType actionElement = null;

            switch (actionRow.Action)
            {
                case "AllocateRegistrySpace":
                    actionElement = new Wix.AllocateRegistrySpace();
                    break;
                case "AppSearch":
                    WixActionRow appSearchActionRow = this.standardActions[actionRow.SequenceTable, actionRow.Action];

                    if (null != actionRow.Before || null != actionRow.After || (null != appSearchActionRow && actionRow.Sequence != appSearchActionRow.Sequence))
                    {
                        Wix.AppSearch appSearch = new Wix.AppSearch();

                        if (null != actionRow.Condition)
                        {
                            appSearch.Content = actionRow.Condition;
                        }

                        if (null != actionRow.Before)
                        {
                            appSearch.Before = actionRow.Before;
                        }
                        else if (null != actionRow.After)
                        {
                            appSearch.After = actionRow.After;
                        }
                        else if (0 < actionRow.Sequence)
                        {
                            appSearch.Sequence = actionRow.Sequence;
                        }

                        return appSearch;
                    }
                    break;
                case "BindImage":
                    actionElement = new Wix.BindImage();
                    break;
                case "CCPSearch":
                    Wix.CCPSearch ccpSearch = new Wix.CCPSearch();
                    Decompiler.SequenceRelativeAction(actionRow, ccpSearch);
                    return ccpSearch;
                case "CostFinalize":
                    actionElement = new Wix.CostFinalize();
                    break;
                case "CostInitialize":
                    actionElement = new Wix.CostInitialize();
                    break;
                case "CreateFolders":
                    actionElement = new Wix.CreateFolders();
                    break;
                case "CreateShortcuts":
                    actionElement = new Wix.CreateShortcuts();
                    break;
                case "DeleteServices":
                    actionElement = new Wix.DeleteServices();
                    break;
                case "DisableRollback":
                    Wix.DisableRollback disableRollback = new Wix.DisableRollback();
                    Decompiler.SequenceRelativeAction(actionRow, disableRollback);
                    return disableRollback;
                case "DuplicateFiles":
                    actionElement = new Wix.DuplicateFiles();
                    break;
                case "ExecuteAction":
                    actionElement = new Wix.ExecuteAction();
                    break;
                case "FileCost":
                    actionElement = new Wix.FileCost();
                    break;
                case "FindRelatedProducts":
                    Wix.FindRelatedProducts findRelatedProducts = new Wix.FindRelatedProducts();
                    Decompiler.SequenceRelativeAction(actionRow, findRelatedProducts);
                    return findRelatedProducts;
                case "ForceReboot":
                    Wix.ForceReboot forceReboot = new Wix.ForceReboot();
                    Decompiler.SequenceRelativeAction(actionRow, forceReboot);
                    return forceReboot;
                case "InstallAdminPackage":
                    actionElement = new Wix.InstallAdminPackage();
                    break;
                case "InstallExecute":
                    Wix.InstallExecute installExecute = new Wix.InstallExecute();
                    Decompiler.SequenceRelativeAction(actionRow, installExecute);
                    return installExecute;
                case "InstallExecuteAgain":
                    Wix.InstallExecuteAgain installExecuteAgain = new Wix.InstallExecuteAgain();
                    Decompiler.SequenceRelativeAction(actionRow, installExecuteAgain);
                    return installExecuteAgain;
                case "InstallFiles":
                    actionElement = new Wix.InstallFiles();
                    break;
                case "InstallFinalize":
                    actionElement = new Wix.InstallFinalize();
                    break;
                case "InstallInitialize":
                    actionElement = new Wix.InstallInitialize();
                    break;
                case "InstallODBC":
                    actionElement = new Wix.InstallODBC();
                    break;
                case "InstallServices":
                    actionElement = new Wix.InstallServices();
                    break;
                case "InstallValidate":
                    actionElement = new Wix.InstallValidate();
                    break;
                case "IsolateComponents":
                    actionElement = new Wix.IsolateComponents();
                    break;
                case "LaunchConditions":
                    Wix.LaunchConditions launchConditions = new Wix.LaunchConditions();
                    Decompiler.SequenceRelativeAction(actionRow, launchConditions);
                    return launchConditions;
                case "MigrateFeatureStates":
                    actionElement = new Wix.MigrateFeatureStates();
                    break;
                case "MoveFiles":
                    actionElement = new Wix.MoveFiles();
                    break;
                case "MsiPublishAssemblies":
                    actionElement = new Wix.MsiPublishAssemblies();
                    break;
                case "MsiUnpublishAssemblies":
                    actionElement = new Wix.MsiUnpublishAssemblies();
                    break;
                case "PatchFiles":
                    actionElement = new Wix.PatchFiles();
                    break;
                case "ProcessComponents":
                    actionElement = new Wix.ProcessComponents();
                    break;
                case "PublishComponents":
                    actionElement = new Wix.PublishComponents();
                    break;
                case "PublishFeatures":
                    actionElement = new Wix.PublishFeatures();
                    break;
                case "PublishProduct":
                    actionElement = new Wix.PublishProduct();
                    break;
                case "RegisterClassInfo":
                    actionElement = new Wix.RegisterClassInfo();
                    break;
                case "RegisterComPlus":
                    actionElement = new Wix.RegisterComPlus();
                    break;
                case "RegisterExtensionInfo":
                    actionElement = new Wix.RegisterExtensionInfo();
                    break;
                case "RegisterFonts":
                    actionElement = new Wix.RegisterFonts();
                    break;
                case "RegisterMIMEInfo":
                    actionElement = new Wix.RegisterMIMEInfo();
                    break;
                case "RegisterProduct":
                    actionElement = new Wix.RegisterProduct();
                    break;
                case "RegisterProgIdInfo":
                    actionElement = new Wix.RegisterProgIdInfo();
                    break;
                case "RegisterTypeLibraries":
                    actionElement = new Wix.RegisterTypeLibraries();
                    break;
                case "RegisterUser":
                    actionElement = new Wix.RegisterUser();
                    break;
                case "RemoveDuplicateFiles":
                    actionElement = new Wix.RemoveDuplicateFiles();
                    break;
                case "RemoveEnvironmentStrings":
                    actionElement = new Wix.RemoveEnvironmentStrings();
                    break;
                case "RemoveExistingProducts":
                    Wix.RemoveExistingProducts removeExistingProducts = new Wix.RemoveExistingProducts();
                    Decompiler.SequenceRelativeAction(actionRow, removeExistingProducts);
                    return removeExistingProducts;
                case "RemoveFiles":
                    actionElement = new Wix.RemoveFiles();
                    break;
                case "RemoveFolders":
                    actionElement = new Wix.RemoveFolders();
                    break;
                case "RemoveIniValues":
                    actionElement = new Wix.RemoveIniValues();
                    break;
                case "RemoveODBC":
                    actionElement = new Wix.RemoveODBC();
                    break;
                case "RemoveRegistryValues":
                    actionElement = new Wix.RemoveRegistryValues();
                    break;
                case "RemoveShortcuts":
                    actionElement = new Wix.RemoveShortcuts();
                    break;
                case "ResolveSource":
                    Wix.ResolveSource resolveSource = new Wix.ResolveSource();
                    Decompiler.SequenceRelativeAction(actionRow, resolveSource);
                    return resolveSource;
                case "RMCCPSearch":
                    Wix.RMCCPSearch rmccpSearch = new Wix.RMCCPSearch();
                    Decompiler.SequenceRelativeAction(actionRow, rmccpSearch);
                    return rmccpSearch;
                case "ScheduleReboot":
                    Wix.ScheduleReboot scheduleReboot = new Wix.ScheduleReboot();
                    Decompiler.SequenceRelativeAction(actionRow, scheduleReboot);
                    return scheduleReboot;
                case "SelfRegModules":
                    actionElement = new Wix.SelfRegModules();
                    break;
                case "SelfUnregModules":
                    actionElement = new Wix.SelfUnregModules();
                    break;
                case "SetODBCFolders":
                    actionElement = new Wix.SetODBCFolders();
                    break;
                case "StartServices":
                    actionElement = new Wix.StartServices();
                    break;
                case "StopServices":
                    actionElement = new Wix.StopServices();
                    break;
                case "UnpublishComponents":
                    actionElement = new Wix.UnpublishComponents();
                    break;
                case "UnpublishFeatures":
                    actionElement = new Wix.UnpublishFeatures();
                    break;
                case "UnregisterClassInfo":
                    actionElement = new Wix.UnregisterClassInfo();
                    break;
                case "UnregisterComPlus":
                    actionElement = new Wix.UnregisterComPlus();
                    break;
                case "UnregisterExtensionInfo":
                    actionElement = new Wix.UnregisterExtensionInfo();
                    break;
                case "UnregisterFonts":
                    actionElement = new Wix.UnregisterFonts();
                    break;
                case "UnregisterMIMEInfo":
                    actionElement = new Wix.UnregisterMIMEInfo();
                    break;
                case "UnregisterProgIdInfo":
                    actionElement = new Wix.UnregisterProgIdInfo();
                    break;
                case "UnregisterTypeLibraries":
                    actionElement = new Wix.UnregisterTypeLibraries();
                    break;
                case "ValidateProductID":
                    actionElement = new Wix.ValidateProductID();
                    break;
                case "WriteEnvironmentStrings":
                    actionElement = new Wix.WriteEnvironmentStrings();
                    break;
                case "WriteIniValues":
                    actionElement = new Wix.WriteIniValues();
                    break;
                case "WriteRegistryValues":
                    actionElement = new Wix.WriteRegistryValues();
                    break;
                default:
                    this.core.OnMessage(WixWarnings.UnknownAction(actionRow.SourceLineNumbers, actionRow.SequenceTable.ToString(), actionRow.Action));
                    return null;
            }

            if (actionElement != null)
            {
                this.SequenceStandardAction(actionRow, actionElement);
            }

            return actionElement;
        }
Example #7
0
File: Linker.cs Project: zooba/wix3
        /// <summary>
        /// Set sequence numbers for all the actions and create rows in the output object.
        /// </summary>
        /// <param name="actionRows">Collection of actions to schedule.</param>
        /// <param name="suppressActionRows">Collection of actions to suppress.</param>
        private void SequenceActions(RowCollection actionRows, RowCollection suppressActionRows)
        {
            WixActionRowCollection overridableActionRows = new WixActionRowCollection();
            WixActionRowCollection requiredActionRows = new WixActionRowCollection();
            ArrayList scheduledActionRows = new ArrayList();

            // gather the required actions for the output type
            if (OutputType.Product == this.activeOutput.Type)
            {
                // AdminExecuteSequence table
                overridableActionRows.Add(this.standardActions[SequenceTable.AdminExecuteSequence, "CostFinalize"]);
                overridableActionRows.Add(this.standardActions[SequenceTable.AdminExecuteSequence, "CostInitialize"]);
                overridableActionRows.Add(this.standardActions[SequenceTable.AdminExecuteSequence, "FileCost"]);
                overridableActionRows.Add(this.standardActions[SequenceTable.AdminExecuteSequence, "InstallAdminPackage"]);
                overridableActionRows.Add(this.standardActions[SequenceTable.AdminExecuteSequence, "InstallFiles"]);
                overridableActionRows.Add(this.standardActions[SequenceTable.AdminExecuteSequence, "InstallFinalize"]);
                overridableActionRows.Add(this.standardActions[SequenceTable.AdminExecuteSequence, "InstallInitialize"]);
                overridableActionRows.Add(this.standardActions[SequenceTable.AdminExecuteSequence, "InstallValidate"]);

                // AdminUISequence table
                overridableActionRows.Add(this.standardActions[SequenceTable.AdminUISequence, "CostFinalize"]);
                overridableActionRows.Add(this.standardActions[SequenceTable.AdminUISequence, "CostInitialize"]);
                overridableActionRows.Add(this.standardActions[SequenceTable.AdminUISequence, "ExecuteAction"]);
                overridableActionRows.Add(this.standardActions[SequenceTable.AdminUISequence, "FileCost"]);

                // AdvtExecuteSequence table
                overridableActionRows.Add(this.standardActions[SequenceTable.AdvtExecuteSequence, "CostFinalize"]);
                overridableActionRows.Add(this.standardActions[SequenceTable.AdvtExecuteSequence, "CostInitialize"]);
                overridableActionRows.Add(this.standardActions[SequenceTable.AdvtExecuteSequence, "InstallFinalize"]);
                overridableActionRows.Add(this.standardActions[SequenceTable.AdvtExecuteSequence, "InstallInitialize"]);
                overridableActionRows.Add(this.standardActions[SequenceTable.AdvtExecuteSequence, "InstallValidate"]);
                overridableActionRows.Add(this.standardActions[SequenceTable.AdvtExecuteSequence, "PublishFeatures"]);
                overridableActionRows.Add(this.standardActions[SequenceTable.AdvtExecuteSequence, "PublishProduct"]);

                // InstallExecuteSequence table
                overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "CostFinalize"]);
                overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "CostInitialize"]);
                overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "FileCost"]);
                overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "InstallFinalize"]);
                overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "InstallInitialize"]);
                overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "InstallValidate"]);
                overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "ProcessComponents"]);
                overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "PublishFeatures"]);
                overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "PublishProduct"]);
                overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "RegisterProduct"]);
                overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "RegisterUser"]);
                overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "UnpublishFeatures"]);
                overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "ValidateProductID"]);

                // InstallUISequence table
                overridableActionRows.Add(this.standardActions[SequenceTable.InstallUISequence, "CostFinalize"]);
                overridableActionRows.Add(this.standardActions[SequenceTable.InstallUISequence, "CostInitialize"]);
                overridableActionRows.Add(this.standardActions[SequenceTable.InstallUISequence, "ExecuteAction"]);
                overridableActionRows.Add(this.standardActions[SequenceTable.InstallUISequence, "FileCost"]);
                overridableActionRows.Add(this.standardActions[SequenceTable.InstallUISequence, "ValidateProductID"]);
            }

            // gather the required actions for each table
            foreach (Table table in this.activeOutput.Tables)
            {
                switch (table.Name)
                {
                    case "AppSearch":
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "AppSearch"], true);
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallUISequence, "AppSearch"], true);
                        break;
                    case "BindImage":
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "BindImage"], true);
                        break;
                    case "CCPSearch":
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "AppSearch"], true);
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "CCPSearch"], true);
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "RMCCPSearch"], true);
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallUISequence, "AppSearch"], true);
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallUISequence, "CCPSearch"], true);
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallUISequence, "RMCCPSearch"], true);
                        break;
                    case "Class":
                        overridableActionRows.Add(this.standardActions[SequenceTable.AdvtExecuteSequence, "RegisterClassInfo"], true);
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "RegisterClassInfo"], true);
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "UnregisterClassInfo"], true);
                        break;
                    case "Complus":
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "RegisterComPlus"], true);
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "UnregisterComPlus"], true);
                        break;
                    case "CreateFolder":
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "CreateFolders"], true);
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "RemoveFolders"], true);
                        break;
                    case "DuplicateFile":
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "DuplicateFiles"], true);
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "RemoveDuplicateFiles"], true);
                        break;
                    case "Environment":
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "WriteEnvironmentStrings"], true);
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "RemoveEnvironmentStrings"], true);
                        break;
                    case "Extension":
                        overridableActionRows.Add(this.standardActions[SequenceTable.AdvtExecuteSequence, "RegisterExtensionInfo"], true);
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "RegisterExtensionInfo"], true);
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "UnregisterExtensionInfo"], true);
                        break;
                    case "File":
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "InstallFiles"], true);
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "RemoveFiles"], true);
                        break;
                    case "Font":
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "RegisterFonts"], true);
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "UnregisterFonts"], true);
                        break;
                    case "IniFile":
                    case "RemoveIniFile":
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "WriteIniValues"], true);
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "RemoveIniValues"], true);
                        break;
                    case "IsolatedComponent":
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "IsolateComponents"], true);
                        break;
                    case "LaunchCondition":
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "LaunchConditions"], true);
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallUISequence, "LaunchConditions"], true);
                        break;
                    case "MIME":
                        overridableActionRows.Add(this.standardActions[SequenceTable.AdvtExecuteSequence, "RegisterMIMEInfo"], true);
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "RegisterMIMEInfo"], true);
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "UnregisterMIMEInfo"], true);
                        break;
                    case "MoveFile":
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "MoveFiles"], true);
                        break;
                    case "MsiAssembly":
                        overridableActionRows.Add(this.standardActions[SequenceTable.AdvtExecuteSequence, "MsiPublishAssemblies"], true);
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "MsiPublishAssemblies"], true);
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "MsiUnpublishAssemblies"], true);
                        break;
                    case "MsiServiceConfig":
                    case "MsiServiceConfigFailureActions":
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "MsiConfigureServices"], true);
                        break;
                    case "ODBCDataSource":
                    case "ODBCTranslator":
                    case "ODBCDriver":
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "SetODBCFolders"], true);
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "InstallODBC"], true);
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "RemoveODBC"], true);
                        break;
                    case "ProgId":
                        overridableActionRows.Add(this.standardActions[SequenceTable.AdvtExecuteSequence, "RegisterProgIdInfo"], true);
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "RegisterProgIdInfo"], true);
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "UnregisterProgIdInfo"], true);
                        break;
                    case "PublishComponent":
                        overridableActionRows.Add(this.standardActions[SequenceTable.AdvtExecuteSequence, "PublishComponents"], true);
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "PublishComponents"], true);
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "UnpublishComponents"], true);
                        break;
                    case "Registry":
                    case "RemoveRegistry":
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "WriteRegistryValues"], true);
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "RemoveRegistryValues"], true);
                        break;
                    case "RemoveFile":
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "RemoveFiles"], true);
                        break;
                    case "SelfReg":
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "SelfRegModules"], true);
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "SelfUnregModules"], true);
                        break;
                    case "ServiceControl":
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "StartServices"], true);
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "StopServices"], true);
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "DeleteServices"], true);
                        break;
                    case "ServiceInstall":
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "InstallServices"], true);
                        break;
                    case "Shortcut":
                        overridableActionRows.Add(this.standardActions[SequenceTable.AdvtExecuteSequence, "CreateShortcuts"], true);
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "CreateShortcuts"], true);
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "RemoveShortcuts"], true);
                        break;
                    case "TypeLib":
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "RegisterTypeLibraries"], true);
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "UnregisterTypeLibraries"], true);
                        break;
                    case "Upgrade":
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "FindRelatedProducts"], true);
                        overridableActionRows.Add(this.standardActions[SequenceTable.InstallUISequence, "FindRelatedProducts"], true);
                        // Only add the MigrateFeatureStates action if MigrateFeature attribute is set to yes on at least one UpgradeVersion element.
                        foreach (Row row in table.Rows)
                        {
                            int options = (int)row[4];
                            if (MsiInterop.MsidbUpgradeAttributesMigrateFeatures == (options & MsiInterop.MsidbUpgradeAttributesMigrateFeatures))
                            {
                                overridableActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "MigrateFeatureStates"], true);
                                overridableActionRows.Add(this.standardActions[SequenceTable.InstallUISequence, "MigrateFeatureStates"], true);
                                break;
                            }
                        }
                        break;
                }
            }

            // index all the action rows (look for collisions)
            foreach (WixActionRow actionRow in actionRows)
            {
                if (actionRow.Overridable) // overridable action
                {
                    WixActionRow collidingActionRow = overridableActionRows[actionRow.SequenceTable, actionRow.Action];

                    if (null != collidingActionRow)
                    {
                        this.OnMessage(WixErrors.OverridableActionCollision(actionRow.SourceLineNumbers, actionRow.SequenceTable.ToString(), actionRow.Action));
                        if (null != collidingActionRow.SourceLineNumbers)
                        {
                            this.OnMessage(WixErrors.OverridableActionCollision2(collidingActionRow.SourceLineNumbers));
                        }
                    }
                    else
                    {
                        overridableActionRows.Add(actionRow);
                    }
                }
                else // unscheduled/scheduled action
                {
                    // unscheduled action (allowed for certain standard actions)
                    if (null == actionRow.Before && null == actionRow.After && 0 == actionRow.Sequence)
                    {
                        WixActionRow standardAction = this.standardActions[actionRow.SequenceTable, actionRow.Action];

                        if (null != standardAction)
                        {
                            // populate the sequence from the standard action
                            actionRow.Sequence = standardAction.Sequence;
                        }
                        else // not a supported unscheduled action
                        {
                            throw new InvalidOperationException(WixStrings.EXP_FoundActionRowWithNoSequenceBeforeOrAfterColumnSet);
                        }
                    }

                    WixActionRow collidingActionRow = requiredActionRows[actionRow.SequenceTable, actionRow.Action];

                    if (null != collidingActionRow)
                    {
                        this.OnMessage(WixErrors.ActionCollision(actionRow.SourceLineNumbers, actionRow.SequenceTable.ToString(), actionRow.Action));
                        if (null != collidingActionRow.SourceLineNumbers)
                        {
                            this.OnMessage(WixErrors.ActionCollision2(collidingActionRow.SourceLineNumbers));
                        }
                    }
                    else
                    {
                        requiredActionRows.Add(actionRow.Clone());
                    }
                }
            }

            // add the overridable action rows that are not overridden to the required action rows
            foreach (WixActionRow actionRow in overridableActionRows)
            {
                if (null == requiredActionRows[actionRow.SequenceTable, actionRow.Action])
                {
                    requiredActionRows.Add(actionRow.Clone());
                }
            }

            // suppress the required actions that are overridable
            foreach (Row suppressActionRow in suppressActionRows)
            {
                SequenceTable sequenceTable = (SequenceTable)Enum.Parse(typeof(SequenceTable), (string)suppressActionRow[0]);
                string action = (string)suppressActionRow[1];

                // get the action being suppressed (if it exists)
                WixActionRow requiredActionRow = requiredActionRows[sequenceTable, action];

                // if there is an overridable row to suppress; suppress it
                // there is no warning if there is no action to suppress because the action may be suppressed from a merge module in the binder
                if (null != requiredActionRow)
                {
                    if (requiredActionRow.Overridable)
                    {
                        this.OnMessage(WixWarnings.SuppressAction(suppressActionRow.SourceLineNumbers, action, sequenceTable.ToString()));
                        if (null != requiredActionRow.SourceLineNumbers)
                        {
                            this.OnMessage(WixWarnings.SuppressAction2(requiredActionRow.SourceLineNumbers));
                        }
                        requiredActionRows.Remove(sequenceTable, action);
                    }
                    else // suppressing a non-overridable action row
                    {
                        this.OnMessage(WixErrors.SuppressNonoverridableAction(suppressActionRow.SourceLineNumbers, sequenceTable.ToString(), action));
                        if (null != requiredActionRow.SourceLineNumbers)
                        {
                            this.OnMessage(WixErrors.SuppressNonoverridableAction2(requiredActionRow.SourceLineNumbers));
                        }
                    }
                }
            }

            // create a copy of the required action rows so that new rows can be added while enumerating
            WixActionRow[] copyOfRequiredActionRows = new WixActionRow[requiredActionRows.Count];
            requiredActionRows.CopyTo(copyOfRequiredActionRows, 0);

            // build up dependency trees of the relatively scheduled actions
            foreach (WixActionRow actionRow in copyOfRequiredActionRows)
            {
                if (0 == actionRow.Sequence)
                {
                    // check for standard actions that don't have a sequence number in a merge module
                    if (OutputType.Module == this.activeOutput.Type && Util.IsStandardAction(actionRow.Action))
                    {
                        this.OnMessage(WixErrors.StandardActionRelativelyScheduledInModule(actionRow.SourceLineNumbers, actionRow.SequenceTable.ToString(), actionRow.Action));
                    }

                    this.SequenceActionRow(actionRow, requiredActionRows);
                }
                else if (OutputType.Module == this.activeOutput.Type && 0 < actionRow.Sequence && !Util.IsStandardAction(actionRow.Action)) // check for custom actions and dialogs that have a sequence number
                {
                    this.OnMessage(WixErrors.CustomActionSequencedInModule(actionRow.SourceLineNumbers, actionRow.SequenceTable.ToString(), actionRow.Action));
                }
            }

            // look for standard actions with sequence restrictions that aren't necessarily scheduled based on the presence of a particular table
            if (requiredActionRows.Contains(SequenceTable.InstallExecuteSequence, "DuplicateFiles") && !requiredActionRows.Contains(SequenceTable.InstallExecuteSequence, "InstallFiles"))
            {
                requiredActionRows.Add(this.standardActions[SequenceTable.InstallExecuteSequence, "InstallFiles"], true);
            }

            // schedule actions
            if (OutputType.Module == this.activeOutput.Type)
            {
                // add the action row to the list of scheduled action rows
                scheduledActionRows.AddRange(requiredActionRows);
            }
            else
            {
                // process each sequence table individually
                foreach (SequenceTable sequenceTable in Enum.GetValues(typeof(SequenceTable)))
                {
                    // create a collection of just the action rows in this sequence
                    WixActionRowCollection sequenceActionRows = new WixActionRowCollection();
                    foreach (WixActionRow actionRow in requiredActionRows)
                    {
                        if (sequenceTable == actionRow.SequenceTable)
                        {
                            sequenceActionRows.Add(actionRow);
                        }
                    }

                    // schedule the absolutely scheduled actions (by sorting them by their sequence numbers)
                    ArrayList absoluteActionRows = new ArrayList();
                    foreach (WixActionRow actionRow in sequenceActionRows)
                    {
                        if (0 != actionRow.Sequence)
                        {
                            // look for sequence number collisions
                            foreach (WixActionRow sequenceScheduledActionRow in absoluteActionRows)
                            {
                                if (sequenceScheduledActionRow.Sequence == actionRow.Sequence)
                                {
                                    this.OnMessage(WixWarnings.ActionSequenceCollision(actionRow.SourceLineNumbers, actionRow.SequenceTable.ToString(), actionRow.Action, sequenceScheduledActionRow.Action, actionRow.Sequence));
                                    if (null != sequenceScheduledActionRow.SourceLineNumbers)
                                    {
                                        this.OnMessage(WixWarnings.ActionSequenceCollision2(sequenceScheduledActionRow.SourceLineNumbers));
                                    }
                                }
                            }

                            absoluteActionRows.Add(actionRow);
                        }
                    }
                    absoluteActionRows.Sort();

                    // schedule the relatively scheduled actions (by resolving the dependency trees)
                    int previousUsedSequence = 0;
                    ArrayList relativeActionRows = new ArrayList();
                    for (int j = 0; j < absoluteActionRows.Count; j++)
                    {
                        WixActionRow absoluteActionRow = (WixActionRow)absoluteActionRows[j];
                        int unusedSequence;

                        // get all the relatively scheduled action rows occuring before this absolutely scheduled action row
                        RowCollection allPreviousActionRows = new RowCollection();
                        absoluteActionRow.GetAllPreviousActionRows(sequenceTable, allPreviousActionRows);

                        // get all the relatively scheduled action rows occuring after this absolutely scheduled action row
                        RowCollection allNextActionRows = new RowCollection();
                        absoluteActionRow.GetAllNextActionRows(sequenceTable, allNextActionRows);

                        // check for relatively scheduled actions occuring before/after a special action (these have a negative sequence number)
                        if (0 > absoluteActionRow.Sequence && (0 < allPreviousActionRows.Count || 0 < allNextActionRows.Count))
                        {
                            // create errors for all the before actions
                            foreach (WixActionRow actionRow in allPreviousActionRows)
                            {
                                this.OnMessage(WixErrors.ActionScheduledRelativeToTerminationAction(actionRow.SourceLineNumbers, actionRow.SequenceTable.ToString(), actionRow.Action, absoluteActionRow.Action));
                            }

                            // create errors for all the after actions
                            foreach (WixActionRow actionRow in allNextActionRows)
                            {
                                this.OnMessage(WixErrors.ActionScheduledRelativeToTerminationAction(actionRow.SourceLineNumbers, actionRow.SequenceTable.ToString(), actionRow.Action, absoluteActionRow.Action));
                            }

                            // if there is source line information for the absolutely scheduled action display it
                            if (null != absoluteActionRow.SourceLineNumbers)
                            {
                                this.OnMessage(WixErrors.ActionScheduledRelativeToTerminationAction2(absoluteActionRow.SourceLineNumbers));
                            }

                            continue;
                        }

                        // schedule the action rows before this one
                        unusedSequence = absoluteActionRow.Sequence - 1;
                        for (int i = allPreviousActionRows.Count - 1; i >= 0; i--)
                        {
                            WixActionRow relativeActionRow = (WixActionRow)allPreviousActionRows[i];

                            // look for collisions
                            if (unusedSequence == previousUsedSequence)
                            {
                                this.OnMessage(WixErrors.NoUniqueActionSequenceNumber(relativeActionRow.SourceLineNumbers, relativeActionRow.SequenceTable.ToString(), relativeActionRow.Action, absoluteActionRow.Action));
                                if (null != absoluteActionRow.SourceLineNumbers)
                                {
                                    this.OnMessage(WixErrors.NoUniqueActionSequenceNumber2(absoluteActionRow.SourceLineNumbers));
                                }

                                unusedSequence++;
                            }

                            relativeActionRow.Sequence = unusedSequence;
                            relativeActionRows.Add(relativeActionRow);

                            unusedSequence--;
                        }

                        // determine the next used action sequence number
                        int nextUsedSequence;
                        if (absoluteActionRows.Count > j + 1)
                        {
                            nextUsedSequence = ((WixActionRow)absoluteActionRows[j + 1]).Sequence;
                        }
                        else
                        {
                            nextUsedSequence = short.MaxValue + 1;
                        }

                        // schedule the action rows after this one
                        unusedSequence = absoluteActionRow.Sequence + 1;
                        for (int i = 0; i < allNextActionRows.Count; i++)
                        {
                            WixActionRow relativeActionRow = (WixActionRow)allNextActionRows[i];

                            if (unusedSequence == nextUsedSequence)
                            {
                                this.OnMessage(WixErrors.NoUniqueActionSequenceNumber(relativeActionRow.SourceLineNumbers, relativeActionRow.SequenceTable.ToString(), relativeActionRow.Action, absoluteActionRow.Action));
                                if (null != absoluteActionRow.SourceLineNumbers)
                                {
                                    this.OnMessage(WixErrors.NoUniqueActionSequenceNumber2(absoluteActionRow.SourceLineNumbers));
                                }

                                unusedSequence--;
                            }

                            relativeActionRow.Sequence = unusedSequence;
                            relativeActionRows.Add(relativeActionRow);

                            unusedSequence++;
                        }

                        // keep track of this sequence number as the previous used sequence number for the next iteration
                        previousUsedSequence = absoluteActionRow.Sequence;
                    }

                    // add the absolutely and relatively scheduled actions to the list of scheduled actions
                    scheduledActionRows.AddRange(absoluteActionRows);
                    scheduledActionRows.AddRange(relativeActionRows);
                }
            }

            // create the action rows for sequences that are not suppressed
            foreach (WixActionRow actionRow in scheduledActionRows)
            {
                // skip actions in suppressed sequences
                if ((this.suppressAdminSequence && (SequenceTable.AdminExecuteSequence == actionRow.SequenceTable || SequenceTable.AdminUISequence == actionRow.SequenceTable)) ||
                    (this.suppressAdvertiseSequence && SequenceTable.AdvtExecuteSequence == actionRow.SequenceTable) ||
                    (this.suppressUISequence && (SequenceTable.AdminUISequence == actionRow.SequenceTable || SequenceTable.InstallUISequence == actionRow.SequenceTable)))
                {
                    continue;
                }

                // get the table definition for the action (and ensure the proper table exists for a module)
                TableDefinition sequenceTableDefinition = null;
                switch (actionRow.SequenceTable)
                {
                    case SequenceTable.AdminExecuteSequence:
                        if (OutputType.Module == this.activeOutput.Type)
                        {
                            this.activeOutput.EnsureTable(this.tableDefinitions["AdminExecuteSequence"]);
                            sequenceTableDefinition = this.tableDefinitions["ModuleAdminExecuteSequence"];
                        }
                        else
                        {
                            sequenceTableDefinition = this.tableDefinitions["AdminExecuteSequence"];
                        }
                        break;
                    case SequenceTable.AdminUISequence:
                        if (OutputType.Module == this.activeOutput.Type)
                        {
                            this.activeOutput.EnsureTable(this.tableDefinitions["AdminUISequence"]);
                            sequenceTableDefinition = this.tableDefinitions["ModuleAdminUISequence"];
                        }
                        else
                        {
                            sequenceTableDefinition = this.tableDefinitions["AdminUISequence"];
                        }
                        break;
                    case SequenceTable.AdvtExecuteSequence:
                        if (OutputType.Module == this.activeOutput.Type)
                        {
                            this.activeOutput.EnsureTable(this.tableDefinitions["AdvtExecuteSequence"]);
                            sequenceTableDefinition = this.tableDefinitions["ModuleAdvtExecuteSequence"];
                        }
                        else
                        {
                            sequenceTableDefinition = this.tableDefinitions["AdvtExecuteSequence"];
                        }
                        break;
                    case SequenceTable.InstallExecuteSequence:
                        if (OutputType.Module == this.activeOutput.Type)
                        {
                            this.activeOutput.EnsureTable(this.tableDefinitions["InstallExecuteSequence"]);
                            sequenceTableDefinition = this.tableDefinitions["ModuleInstallExecuteSequence"];
                        }
                        else
                        {
                            sequenceTableDefinition = this.tableDefinitions["InstallExecuteSequence"];
                        }
                        break;
                    case SequenceTable.InstallUISequence:
                        if (OutputType.Module == this.activeOutput.Type)
                        {
                            this.activeOutput.EnsureTable(this.tableDefinitions["InstallUISequence"]);
                            sequenceTableDefinition = this.tableDefinitions["ModuleInstallUISequence"];
                        }
                        else
                        {
                            sequenceTableDefinition = this.tableDefinitions["InstallUISequence"];
                        }
                        break;
                }

                // create the action sequence row in the output
                Table sequenceTable = this.activeOutput.EnsureTable(sequenceTableDefinition);
                Row row = sequenceTable.CreateRow(actionRow.SourceLineNumbers);
                if (this.sectionIdOnRows)
                {
                    row.SectionId = actionRow.SectionId;
                }

                if (OutputType.Module == this.activeOutput.Type)
                {
                    row[0] = actionRow.Action;
                    if (0 != actionRow.Sequence)
                    {
                        row[1] = actionRow.Sequence;
                    }
                    else
                    {
                        bool after = (null == actionRow.Before);
                        row[2] = after ? actionRow.After : actionRow.Before;
                        row[3] = after ? 1 : 0;
                    }
                    row[4] = actionRow.Condition;
                }
                else
                {
                    row[0] = actionRow.Action;
                    row[1] = actionRow.Condition;
                    row[2] = actionRow.Sequence;
                }
            }
        }
Example #8
0
File: Table.cs Project: zooba/wix3
        /// <summary>
        /// Creates a new row in the table.
        /// </summary>
        /// <param name="sourceLineNumbers">Original source lines for this row.</param>
        /// <param name="add">Specifies whether to only create the row or add it to the table automatically.</param>
        /// <returns>Row created in table.</returns>
        public Row CreateRow(SourceLineNumberCollection sourceLineNumbers, bool add)
        {
            Row row;

            switch (this.Name)
            {
                case "BBControl":
                    row = new BBControlRow(sourceLineNumbers, this);
                    break;
                case "ChainMsiPackage":
                    row = new ChainMsiPackageRow(sourceLineNumbers, this);
                    break;
                case "Component":
                    row = new ComponentRow(sourceLineNumbers, this);
                    break;
                case "Control":
                    row = new ControlRow(sourceLineNumbers, this);
                    break;
                case "File":
                    row = new FileRow(sourceLineNumbers, this);
                    break;
                case "Media":
                    row = new MediaRow(sourceLineNumbers, this);
                    break;
                case "PayloadInfo":
                    row = new PayloadInfoRow(sourceLineNumbers, this);
                    break;
                case "Upgrade":
                    row = new UpgradeRow(sourceLineNumbers, this);
                    break;
                case "Variable":
                    row = new VariableRow(sourceLineNumbers, this);
                    break;
                case "WixAction":
                    row = new WixActionRow(sourceLineNumbers, this);
                    break;
                case "WixApprovedExeForElevation":
                    row = new WixApprovedExeForElevationRow(sourceLineNumbers, this);
                    break;
                case "WixBundle":
                    row = new WixBundleRow(sourceLineNumbers, this);
                    break;
                case "WixBundlePatchTargetCode":
                    row = new WixBundlePatchTargetCodeRow(sourceLineNumbers, this);
                    break;
                case "WixBundleUpdate":
                    row = new WixBundleUpdateRow(sourceLineNumbers, this);
                    break;
                case "WixCatalog":
                    row = new WixCatalogRow(sourceLineNumbers, this);
                    break;
                case "WixCommandLine":
                    row = new WixCommandLineRow(sourceLineNumbers, this);
                    break;
                case "WixComplexReference":
                    row = new WixComplexReferenceRow(sourceLineNumbers, this);
                    break;
                case "WixFile":
                    row = new WixFileRow(sourceLineNumbers, this);
                    break;
                case "WixMedia":
                    row = new WixMediaRow(sourceLineNumbers, this);
                    break;
                case "WixMediaTemplate":
                    row = new WixMediaTemplateRow(sourceLineNumbers, this);
                    break;
                case "WixMerge":
                    row = new WixMergeRow(sourceLineNumbers, this);
                    break;
                case "WixProperty":
                    row = new WixPropertyRow(sourceLineNumbers, this);
                    break;
                case "WixSimpleReference":
                    row = new WixSimpleReferenceRow(sourceLineNumbers, this);
                    break;
                case "WixUpdateRegistration":
                    row = new WixUpdateRegistrationRow(sourceLineNumbers, this);
                    break;
                case "WixVariable":
                    row = new WixVariableRow(sourceLineNumbers, this);
                    break;

                default:
                    row = new Row(sourceLineNumbers, this);
                    break;
            }

            if (add)
            {
                this.rows.Add(row);
            }

            return row;
        }
Example #9
0
File: Linker.cs Project: zooba/wix3
        private void SequenceActionRow(WixActionRow actionRow, WixActionRowCollection requiredActionRows)
        {
            bool after = false;
            if (actionRow.After != null)
            {
                after = true;
            }
            else if (actionRow.Before == null)
            {
                throw new InvalidOperationException(WixStrings.EXP_FoundActionRowWithNoSequenceBeforeOrAfterColumnSet);
            }

            string parentActionName = (after ? actionRow.After : actionRow.Before);
            WixActionRow parentActionRow = requiredActionRows[actionRow.SequenceTable, parentActionName];

            if (null == parentActionRow)
            {
                parentActionRow = this.standardActions[actionRow.SequenceTable, parentActionName];

                // if the missing parent action is a standard action (with a suggested sequence number), add it
                if (null != parentActionRow)
                {
                    // Create a clone to avoid modifying the static copy of the object.
                    parentActionRow = parentActionRow.Clone();
                    requiredActionRows.Add(parentActionRow);
                }
                else
                {
                    throw new InvalidOperationException(String.Format(CultureInfo.CurrentUICulture, WixStrings.EXP_FoundActionRowWinNonExistentAction, (after ? "After" : "Before"), parentActionName));
                }
            }
            else if (actionRow == parentActionRow || actionRow.ContainsChildActionRow(parentActionRow)) // cycle detected
            {
                throw new WixException(WixErrors.ActionCircularDependency(actionRow.SourceLineNumbers, actionRow.SequenceTable.ToString(), actionRow.Action, parentActionRow.Action));
            }

            // Add this action to the appropriate list of dependent action rows.
            WixActionRowCollection relatedRows = (after ? parentActionRow.NextActionRows : parentActionRow.PreviousActionRows);
            relatedRows.Add(actionRow);
        }
Example #10
0
 /// <summary>
 /// Instantiates an ActionRow by copying data from another ActionRow.
 /// </summary>
 /// <param name="source">The row the data is copied from.</param>
 /// <remarks>The previous and next action collections are not copied.</remarks>
 private WixActionRow(WixActionRow source)
     : base(source)
 {
 }
Example #11
0
        /// <summary>
        /// Determines whether this ActionRow contains the specified ActionRow as a child in its dependency tree.
        /// </summary>
        /// <param name="actionRow">The possible child ActionRow.</param>
        /// <returns>true if the ActionRow is a child of this ActionRow; false otherwise.</returns>
        internal bool ContainsChildActionRow(WixActionRow actionRow)
        {
            if (null != this.previousActionRows)
            {
                if (this.previousActionRows.Contains(actionRow.SequenceTable, actionRow.Action))
                {
                    return true;
                }
            }

            if (null != this.nextActionRows)
            {
                if (this.nextActionRows.Contains(actionRow.SequenceTable, actionRow.Action))
                {
                    return true;
                }
            }

            return false;
        }
Example #12
0
        /// <summary>
        /// Parses ActionRows from the Xml reader.
        /// </summary>
        /// <param name="reader">Xml reader that contains serialized ActionRows.</param>
        /// <returns>The parsed ActionRows.</returns>
        internal static WixActionRow[] Parse(XmlReader reader)
        {
            Debug.Assert("action" == reader.LocalName);

            string id = null;
            string condition = null;
            bool empty = reader.IsEmptyElement;
            int sequence = int.MinValue;
            int sequenceCount = 0;
            SequenceTable[] sequenceTables = new SequenceTable[Enum.GetValues(typeof(SequenceTable)).Length];

            while (reader.MoveToNextAttribute())
            {
                switch (reader.Name)
                {
                    case "name":
                        id = reader.Value;
                        break;
                    case "AdminExecuteSequence":
                        if (Common.IsYes(SourceLineNumberCollection.FromUri(reader.BaseURI), "action", reader.Name, reader.Value))
                        {
                            sequenceTables[sequenceCount] = SequenceTable.AdminExecuteSequence;
                            ++sequenceCount;
                        }
                        break;
                    case "AdminUISequence":
                        if (Common.IsYes(SourceLineNumberCollection.FromUri(reader.BaseURI), "action", reader.Name, reader.Value))
                        {
                            sequenceTables[sequenceCount] = SequenceTable.AdminUISequence;
                            ++sequenceCount;
                        }
                        break;
                    case "AdvtExecuteSequence":
                        if (Common.IsYes(SourceLineNumberCollection.FromUri(reader.BaseURI), "action", reader.Name, reader.Value))
                        {
                            sequenceTables[sequenceCount] = SequenceTable.AdvtExecuteSequence;
                            ++sequenceCount;
                        }
                        break;
                    case "condition":
                        condition = reader.Value;
                        break;
                    case "InstallExecuteSequence":
                        if (Common.IsYes(SourceLineNumberCollection.FromUri(reader.BaseURI), "action", reader.Name, reader.Value))
                        {
                            sequenceTables[sequenceCount] = SequenceTable.InstallExecuteSequence;
                            ++sequenceCount;
                        }
                        break;
                    case "InstallUISequence":
                        if (Common.IsYes(SourceLineNumberCollection.FromUri(reader.BaseURI), "action", reader.Name, reader.Value))
                        {
                            sequenceTables[sequenceCount] = SequenceTable.InstallUISequence;
                            ++sequenceCount;
                        }
                        break;
                    case "sequence":
                        sequence = Convert.ToInt32(reader.Value, CultureInfo.InvariantCulture);
                        break;
                    default:
                        if (!reader.NamespaceURI.StartsWith("http://www.w3.org/", StringComparison.Ordinal))
                        {
                            throw new WixException(WixErrors.UnexpectedAttribute(SourceLineNumberCollection.FromUri(reader.BaseURI), "action", reader.Name));
                        }
                        break;
                }
            }

            if (null == id)
            {
                throw new WixException(WixErrors.ExpectedAttribute(SourceLineNumberCollection.FromUri(reader.BaseURI), "action", "name"));
            }

            if (int.MinValue == sequence)
            {
                throw new WixException(WixErrors.ExpectedAttribute(SourceLineNumberCollection.FromUri(reader.BaseURI), "action", "sequence"));
            }
            else if (1 > sequence)
            {
                throw new WixException(WixErrors.IntegralValueOutOfRange(SourceLineNumberCollection.FromUri(reader.BaseURI), "action", "sequence", sequence, 1, int.MaxValue));
            }

            if (0 == sequenceCount)
            {
                throw new WixException(WixErrors.ExpectedAttributes(SourceLineNumberCollection.FromUri(reader.BaseURI), "action", "AdminExecuteSequence", "AdminUISequence", "AdvtExecuteSequence", "InstallExecuteSequence", "InstallUISequence"));
            }

            if (!empty && reader.Read() && XmlNodeType.EndElement != reader.MoveToContent())
            {
                throw new WixException(WixErrors.UnexpectedContentNode(SourceLineNumberCollection.FromUri(reader.BaseURI), "action", reader.NodeType.ToString()));
            }

            // create the actions
            WixActionRow[] actionRows = new WixActionRow[sequenceCount];
            for (int i = 0; i < sequenceCount; i++)
            {
                WixActionRow actionRow = new WixActionRow(sequenceTables[i], id, condition, sequence);
                actionRows[i] = actionRow;
            }

            return actionRows;
        }
Example #13
0
        /// <summary>
        /// Creates a new row in the table.
        /// </summary>
        /// <param name="sourceLineNumbers">Original source lines for this row.</param>
        /// <returns>Row created in table.</returns>
        public Row CreateRow(SourceLineNumberCollection sourceLineNumbers)
        {
            Row row;

            switch (this.Name)
            {
                case "BBControl":
                    row = new BBControlRow(sourceLineNumbers, this);
                    break;
                case "ChainMsiPackage":
                    row = new ChainMsiPackageRow(sourceLineNumbers, this);
                    break;
                case "Component":
                    row = new ComponentRow(sourceLineNumbers, this);
                    break;
                case "Control":
                    row = new ControlRow(sourceLineNumbers, this);
                    break;
                case "File":
                    row = new FileRow(sourceLineNumbers, this);
                    break;
                case "Media":
                    row = new MediaRow(sourceLineNumbers, this);
                    break;
                case "PayloadInfo":
                    row = new PayloadInfoRow(sourceLineNumbers, this);
                    break;
                case "Upgrade":
                    row = new UpgradeRow(sourceLineNumbers, this);
                    break;
                case "WixAction":
                    row = new WixActionRow(sourceLineNumbers, this);
                    break;
                case "WixComplexReference":
                    row = new WixComplexReferenceRow(sourceLineNumbers, this);
                    break;
                case "WixFile":
                    row = new WixFileRow(sourceLineNumbers, this);
                    break;
                case "WixMedia":
                    row = new WixMediaRow(sourceLineNumbers, this);
                    break;
                case "WixMediaTemplate":
                    row = new WixMediaTemplateRow(sourceLineNumbers, this);
                    break;
                case "WixMerge":
                    row = new WixMergeRow(sourceLineNumbers, this);
                    break;
                case "WixProperty":
                    row = new WixPropertyRow(sourceLineNumbers, this);
                    break;
                case "WixSimpleReference":
                    row = new WixSimpleReferenceRow(sourceLineNumbers, this);
                    break;
                case "WixVariable":
                    row = new WixVariableRow(sourceLineNumbers, this);
                    break;

                default:
                    row = new Row(sourceLineNumbers, this);
                    break;
            }

            this.rows.Add(row);

            return row;
        }