Beispiel #1
0
        /// <summary>
        /// Creates a new action table object and populates it from an Xml reader.
        /// </summary>
        /// <param name="reader">Reader to get data from.</param>
        /// <returns>The parsed ActionTable.</returns>
        private static WixActionRowCollection Parse(XmlReader reader)
        {
            if (!reader.LocalName.Equals("actions"))
            {
                throw new XmlException();
            }

            WixActionRowCollection actionRows = new WixActionRowCollection();
            bool empty = reader.IsEmptyElement;

            while (reader.MoveToNextAttribute())
            {
            }

            if (!empty)
            {
                bool done = false;

                // loop through all the fields in a row
                while (!done && reader.Read())
                {
                    switch (reader.NodeType)
                    {
                    case XmlNodeType.Element:
                        switch (reader.LocalName)
                        {
                        case "action":
                            WixActionRow[] parsedActionRows = WixActionRow.Parse(reader);

                            foreach (WixActionRow actionRow in parsedActionRows)
                            {
                                actionRows.Add(actionRow);
                            }
                            break;

                        default:
                            throw new XmlException();
                        }
                        break;

                    case XmlNodeType.EndElement:
                        done = true;
                        break;
                    }
                }

                if (!done)
                {
                    throw new XmlException();
                }
            }

            return(actionRows);
        }
Beispiel #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);
            }
        }
Beispiel #3
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>
        public 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);
        }
Beispiel #4
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)
 {
 }
Beispiel #5
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 (reader.Value.Equals("yes"))
                    {
                        sequenceTables[sequenceCount] = SequenceTable.AdminExecuteSequence;
                        ++sequenceCount;
                    }
                    break;

                case "AdminUISequence":
                    if (reader.Value.Equals("yes"))
                    {
                        sequenceTables[sequenceCount] = SequenceTable.AdminUISequence;
                        ++sequenceCount;
                    }
                    break;

                case "AdvtExecuteSequence":
                    if (reader.Value.Equals("yes"))
                    {
                        sequenceTables[sequenceCount] = SequenceTable.AdvtExecuteSequence;
                        ++sequenceCount;
                    }
                    break;

                case "condition":
                    condition = reader.Value;
                    break;

                case "InstallExecuteSequence":
                    if (reader.Value.Equals("yes"))
                    {
                        sequenceTables[sequenceCount] = SequenceTable.InstallExecuteSequence;
                        ++sequenceCount;
                    }
                    break;

                case "InstallUISequence":
                    if (reader.Value.Equals("yes"))
                    {
                        sequenceTables[sequenceCount] = SequenceTable.InstallUISequence;
                        ++sequenceCount;
                    }
                    break;

                case "sequence":
                    sequence = Convert.ToInt32(reader.Value, CultureInfo.InvariantCulture);
                    break;
                }
            }

            if (null == id)
            {
                throw new XmlException();
            }

            if (int.MinValue == sequence)
            {
                throw new XmlException();
            }
            else if (1 > sequence)
            {
                throw new XmlException();
            }

            if (0 == sequenceCount)
            {
                throw new XmlException();
            }

            if (!empty && reader.Read() && XmlNodeType.EndElement != reader.MoveToContent())
            {
                throw new XmlException();
            }

            // 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);
        }
Beispiel #6
0
        /// <summary>
        /// Compares the current instance with another object of the same type.
        /// </summary>
        /// <param name="obj">Other reference to compare this one to.</param>
        /// <returns>Returns less than 0 for less than, 0 for equals, and greater than 0 for greater.</returns>
        public int CompareTo(object obj)
        {
            WixActionRow otherActionRow = (WixActionRow)obj;

            return(this.Sequence.CompareTo(otherActionRow.Sequence));
        }
Beispiel #7
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);
 }