示例#1
0
文件: Output.cs 项目: 2dave/Data
        /// <summary>
        /// Processes an XmlReader and builds up the output object.
        /// </summary>
        /// <param name="reader">Reader to get data from.</param>
        /// <param name="suppressVersionCheck">Suppresses wix.dll version mismatch check.</param>
        /// <returns>The Output represented by the Xml.</returns>
        internal static Output Read(XmlReader reader, bool suppressVersionCheck)
        {
            if (!reader.LocalName.Equals("wixOutput"))
            {
                throw new XmlException();
            }

            bool    empty   = reader.IsEmptyElement;
            Output  output  = new Output(SourceLineNumber.CreateFromUri(reader.BaseURI));
            Version version = null;

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "codepage":
                    output.Codepage = Convert.ToInt32(reader.Value, CultureInfo.InvariantCulture.NumberFormat);
                    break;

                case "type":
                    switch (reader.Value)
                    {
                    case "Bundle":
                        output.Type = OutputType.Bundle;
                        break;

                    case "Module":
                        output.Type = OutputType.Module;
                        break;

                    case "Patch":
                        output.Type = OutputType.Patch;
                        break;

                    case "PatchCreation":
                        output.Type = OutputType.PatchCreation;
                        break;

                    case "Product":
                        output.Type = OutputType.Product;
                        break;

                    case "Transform":
                        output.Type = OutputType.Transform;
                        break;

                    default:
                        throw new XmlException();
                    }
                    break;

                case "version":
                    version = new Version(reader.Value);
                    break;
                }
            }

            if (!suppressVersionCheck && null != version && !Output.CurrentVersion.Equals(version))
            {
                throw new WixException(ErrorMessages.VersionMismatch(SourceLineNumber.CreateFromUri(reader.BaseURI), "wixOutput", version.ToString(), Output.CurrentVersion.ToString()));
            }

            // loop through the rest of the xml building up the Output object
            TableDefinitionCollection tableDefinitions = null;
            List <Table> tables = new List <Table>();

            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 "subStorage":
                            output.SubStorages.Add(SubStorage.Read(reader));
                            break;

                        case "table":
                            if (null == tableDefinitions)
                            {
                                throw new XmlException();
                            }
                            tables.Add(Table.Read(reader, tableDefinitions));
                            break;

                        case "tableDefinitions":
                            tableDefinitions = TableDefinitionCollection.Read(reader);
                            break;

                        default:
                            throw new XmlException();
                        }
                        break;

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

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

            output.Tables = new TableIndexedCollection(tables);
            return(output);
        }
示例#2
0
        /// <summary>
        /// Processes an XmlReader and builds up the pdb object.
        /// </summary>
        /// <param name="reader">Reader to get data from.</param>
        /// <param name="suppressVersionCheck">Suppresses wix.dll version mismatch check.</param>
        /// <returns>The Pdb represented by the Xml.</returns>
        internal static Pdb Read(XmlReader reader, bool suppressVersionCheck)
        {
            if ("wixPdb" != reader.LocalName)
            {
                throw new XmlException();
            }

            bool    empty   = reader.IsEmptyElement;
            Pdb     pdb     = new Pdb();
            Version version = null;

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

            if (!suppressVersionCheck && null != version && !Pdb.CurrentVersion.Equals(version))
            {
                throw new WixException(ErrorMessages.VersionMismatch(SourceLineNumber.CreateFromUri(reader.BaseURI), "wixPdb", version.ToString(), Pdb.CurrentVersion.ToString()));
            }

            // loop through the rest of the pdb building up the Output object
            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 "wixOutput":
                            pdb.Output = Output.Read(reader, suppressVersionCheck);
                            break;

                        default:
                            throw new XmlException();
                        }
                        break;

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

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

            return(pdb);
        }
示例#3
0
        /// <summary>
        /// Parses table definition from xml reader.
        /// </summary>
        /// <param name="reader">Reader to get data from.</param>
        /// <param name="tableDefinitions">Table definitions to use for strongly-typed rows.</param>
        /// <returns>The TableDefintion represented by the Xml.</returns>
        internal static TableDefinition Read(XmlReader reader, TableDefinitionCollection tableDefinitions)
        {
            var    empty = reader.IsEmptyElement;
            string name  = null;
            IntermediateSymbolDefinition symbolDefinition = null;
            var  unreal = false;
            var  symbolIdIsPrimaryKey = false;
            Type strongRowType        = null;

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

                case "unreal":
                    unreal = reader.Value.Equals("yes");
                    break;
                }
            }

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

            if (tableDefinitions.TryGet(name, out var tableDefinition))
            {
                symbolDefinition     = tableDefinition.SymbolDefinition;
                symbolIdIsPrimaryKey = tableDefinition.SymbolIdIsPrimaryKey;
                strongRowType        = tableDefinition.StrongRowType;
            }

            var columns             = new List <ColumnDefinition>();
            var hasPrimaryKeyColumn = false;

            // parse the child elements
            if (!empty)
            {
                var done = false;

                while (!done && reader.Read())
                {
                    switch (reader.NodeType)
                    {
                    case XmlNodeType.Element:
                        switch (reader.LocalName)
                        {
                        case "columnDefinition":
                            var columnDefinition = ColumnDefinition.Read(reader);
                            columns.Add(columnDefinition);

                            if (columnDefinition.PrimaryKey)
                            {
                                hasPrimaryKeyColumn = true;
                            }
                            break;

                        default:
                            throw new XmlException();
                        }
                        break;

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

                if (!unreal && !hasPrimaryKeyColumn)
                {
                    throw new WixException(ErrorMessages.RealTableMissingPrimaryKeyColumn(SourceLineNumber.CreateFromUri(reader.BaseURI), name));
                }

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

            return(new TableDefinition(name, symbolDefinition, columns.ToArray(), unreal, symbolIdIsPrimaryKey, strongRowType));
        }
示例#4
0
        /// <summary>
        /// Parses table definition from xml reader.
        /// </summary>
        /// <param name="reader">Reader to get data from.</param>
        /// <returns>The TableDefintion represented by the Xml.</returns>
        internal static TableDefinition Read(XmlReader reader)
        {
            var    empty  = reader.IsEmptyElement;
            string name   = null;
            var    unreal = false;
            var    bootstrapperApplicationData = false;

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

                case "unreal":
                    unreal = reader.Value.Equals("yes");
                    break;

                case "bootstrapperApplicationData":
                    bootstrapperApplicationData = reader.Value.Equals("yes");
                    break;
                }
            }

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

            var columns             = new List <ColumnDefinition>();
            var hasPrimaryKeyColumn = false;

            // parse the child elements
            if (!empty)
            {
                var done = false;

                while (!done && reader.Read())
                {
                    switch (reader.NodeType)
                    {
                    case XmlNodeType.Element:
                        switch (reader.LocalName)
                        {
                        case "columnDefinition":
                            var columnDefinition = ColumnDefinition.Read(reader);
                            columns.Add(columnDefinition);

                            if (columnDefinition.PrimaryKey)
                            {
                                hasPrimaryKeyColumn = true;
                            }
                            break;

                        default:
                            throw new XmlException();
                        }
                        break;

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

                if (!unreal && !bootstrapperApplicationData && !hasPrimaryKeyColumn)
                {
                    throw new WixException(ErrorMessages.RealTableMissingPrimaryKeyColumn(SourceLineNumber.CreateFromUri(reader.BaseURI), name));
                }

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

            return(new TableDefinition(name, columns.ToArray(), unreal, bootstrapperApplicationData));
        }