Exemple #1
0
        /// <summary>
        /// Parse an intermediate from an XML format.
        /// </summary>
        /// <param name="reader">XmlReader where the intermediate is persisted.</param>
        /// <param name="tableDefinitions">TableDefinitions to use in the intermediate.</param>
        /// <param name="suppressVersionCheck">Suppress checking for wix.dll version mismatch.</param>
        /// <returns>The parsed Intermediate.</returns>
        private static Intermediate Read(XmlReader reader, TableDefinitionCollection tableDefinitions, bool suppressVersionCheck)
        {
            if ("wixObject" != reader.LocalName)
            {
                throw new XmlException();
            }

            bool    empty      = reader.IsEmptyElement;
            Version objVersion = null;
            string  id         = null;

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "version":
                    objVersion = new Version(reader.Value);
                    break;

                case "id":
                    id = reader.Value;
                    break;
                }
            }

            if (!suppressVersionCheck && null != objVersion && !Intermediate.CurrentVersion.Equals(objVersion))
            {
                throw new WixException(WixDataErrors.VersionMismatch(SourceLineNumber.CreateFromUri(reader.BaseURI), "object", objVersion.ToString(), Intermediate.CurrentVersion.ToString()));
            }

            Intermediate intermediate = new Intermediate();

            intermediate.id = id;

            if (!empty)
            {
                bool done = false;

                while (!done && reader.Read())
                {
                    switch (reader.NodeType)
                    {
                    case XmlNodeType.Element:
                        switch (reader.LocalName)
                        {
                        case "section":
                            intermediate.AddSection(Section.Read(reader, tableDefinitions));
                            break;

                        default:
                            throw new XmlException();
                        }
                        break;

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

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

            return(intermediate);
        }
Exemple #2
0
 /// <summary>
 /// Creates a shallow copy of the provided table definition collection.
 /// </summary>
 public TableDefinitionCollection(TableDefinitionCollection tableDefinitions)
 {
     this.collection = new Dictionary <string, TableDefinition>(tableDefinitions.collection);
 }