Ejemplo n.º 1
0
        /// <summary>
        /// Parse a table from the xml.
        /// </summary>
        /// <param name="reader">XmlReader where the intermediate is persisted.</param>
        /// <param name="section">Section to populate with persisted data.</param>
        /// <param name="tableDefinitions">TableDefinitions to use in the intermediate.</param>
        /// <returns>The parsed table.</returns>
        internal static Table Parse(XmlReader reader, Section section, TableDefinitionCollection tableDefinitions)
        {
            Debug.Assert("table" == reader.LocalName);

            bool           empty     = reader.IsEmptyElement;
            TableOperation operation = TableOperation.None;
            string         name      = null;

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "name":
                    name = reader.Value;
                    break;

                case "op":
                    switch (reader.Value)
                    {
                    case "add":
                        operation = TableOperation.Add;
                        break;

                    case "drop":
                        operation = TableOperation.Drop;
                        break;

                    default:
                        throw new WixException(WixErrors.IllegalAttributeValue(SourceLineNumber.CreateFromUri(reader.BaseURI), "table", reader.Name, reader.Value, "Add", "Drop"));
                    }
                    break;

                default:
                    if (!reader.NamespaceURI.StartsWith("http://www.w3.org/", StringComparison.Ordinal))
                    {
                        throw new WixException(WixErrors.UnexpectedAttribute(SourceLineNumber.CreateFromUri(reader.BaseURI), "table", reader.Name));
                    }
                    break;
                }
            }

            if (null == name)
            {
                throw new WixException(WixErrors.ExpectedAttribute(SourceLineNumber.CreateFromUri(reader.BaseURI), "table", "name"));
            }

            TableDefinition tableDefinition = tableDefinitions[name];
            Table           table           = new Table(section, tableDefinition);

            table.Operation = operation;

            if (!empty)
            {
                bool done = false;

                // loop through all the rows in a table
                while (!done && reader.Read())
                {
                    switch (reader.NodeType)
                    {
                    case XmlNodeType.Element:
                        switch (reader.LocalName)
                        {
                        case "row":
                            Row.Parse(reader, table);
                            break;

                        default:
                            throw new WixException(WixErrors.UnexpectedElement(SourceLineNumber.CreateFromUri(reader.BaseURI), "table", reader.Name));
                        }
                        break;

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

                if (!done)
                {
                    throw new WixException(WixErrors.ExpectedEndElement(SourceLineNumber.CreateFromUri(reader.BaseURI), "table"));
                }
            }

            return(table);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Creates a table in a section.
 /// </summary>
 /// <param name="section">Section to add table to.</param>
 /// <param name="tableDefinition">Definition of the table.</param>
 public Table(Section section, TableDefinition tableDefinition)
 {
     this.section         = section;
     this.tableDefinition = tableDefinition;
     this.rows            = new RowCollection();
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Creates a WixVariable row that does not belong to a table.
 /// </summary>
 /// <param name="sourceLineNumbers">Original source lines for this row.</param>
 /// <param name="tableDef">TableDefinition this Media row belongs to and should get its column definitions from.</param>
 public WixVariableRow(SourceLineNumber sourceLineNumbers, TableDefinition tableDef) :
     base(sourceLineNumbers, tableDef)
 {
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Creates a PatchTargetCodeRow row that does not belong to a table.
 /// </summary>
 /// <param name="sourceLineNumbers">Original source lines for this row.</param>
 /// <param name="tableDef">TableDefinition this PatchTargetCode row belongs to and should get its column definitions from.</param>
 public WixBundlePatchTargetCodeRow(SourceLineNumber sourceLineNumbers, TableDefinition tableDef) :
     base(sourceLineNumbers, tableDef)
 {
 }
 /// <summary>
 /// Creates a WixUpdateRegistrationRow row that does not belong to a table.
 /// </summary>
 /// <param name="sourceLineNumbers">Original source lines for this row.</param>
 /// <param name="tableDef">TableDefinition this WixUpdateRegistrationRow row belongs to and should get its column definitions from.</param>
 public WixUpdateRegistrationRow(SourceLineNumber sourceLineNumbers, TableDefinition tableDef) :
     base(sourceLineNumbers, tableDef)
 {
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Creates a WixSimpleReferenceRow that belongs to a table.
 /// </summary>
 /// <param name="sourceLineNumbers">Original source lines for this row.</param>
 /// <param name="tableDefinitions">Table definitions for this row.</param>
 public WixSimpleReferenceRow(SourceLineNumber sourceLineNumbers, TableDefinition tableDefinitions)
     : base(sourceLineNumbers, tableDefinitions)
 {
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Ensure this output contains a particular table.
 /// </summary>
 /// <param name="tableDefinition">Definition of the table that should exist.</param>
 /// <returns>The table in this output.</returns>
 internal Table EnsureTable(TableDefinition tableDefinition)
 {
     return(this.tables.EnsureTable(this.entrySection, tableDefinition));
 }