Exemplo n.º 1
0
 public static Message RequiredAttributeNotUnderComponent(SourceLineNumber sourceLineNumbers, string elementName, string attributeName1, string attributeName2)
 {
     return(Message(sourceLineNumbers, Ids.RequiredAttributeNotUnderComponent, "A {0} element not nested under a component must have either a {1} attribute or a {2} attribute, or both set.", elementName, attributeName1, attributeName2));
 }
Exemplo n.º 2
0
 public static Message RequiredAttributeUnderComponent(SourceLineNumber sourceLineNumbers, string elementName, string attributeName)
 {
     return(Message(sourceLineNumbers, Ids.RequiredAttributeUnderComponent, "The {0}/@{1} attribute must be provided when {0} element is nested under a component.", elementName, attributeName));
 }
 private static Message Message(SourceLineNumber sourceLineNumber, Ids id, ResourceManager resourceManager, string resourceName, params object[] args)
 {
     return(new Message(sourceLineNumber, MessageLevel.Verbose, (int)id, resourceManager, resourceName, args));
 }
Exemplo n.º 4
0
 public static Message MimeMapExtensionMissingPeriod(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string attributeValue)
 {
     return(Message(sourceLineNumbers, Ids.MimeMapExtensionMissingPeriod, "The {0}/@{1} attribute's value, '{2}', is not a valid mime map extension.  It must begin with a period.", elementName, attributeName, attributeValue));
 }
Exemplo n.º 5
0
        /// <summary>
        /// Parse the root library element.
        /// </summary>
        /// <param name="reader">XmlReader with library persisted as Xml.</param>
        /// <param name="tableDefinitions">Collection containing TableDefinitions to use when reconstituting the intermediates.</param>
        /// <param name="suppressVersionCheck">Suppresses check for wix.dll version mismatch.</param>
        /// <returns>The parsed Library.</returns>
        private static Library Read(XmlReader reader, TableDefinitionCollection tableDefinitions, bool suppressVersionCheck)
        {
            if (!reader.LocalName.Equals("wixLibrary"))
            {
                throw new XmlException();
            }

            bool    empty   = reader.IsEmptyElement;
            Library library = new Library();
            Version version = null;

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

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

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

            if (!empty)
            {
                bool done = false;

                while (!done && (XmlNodeType.Element == reader.NodeType || reader.Read()))
                {
                    switch (reader.NodeType)
                    {
                    case XmlNodeType.Element:
                        switch (reader.LocalName)
                        {
                        case "localization":
                            Localization localization = Localization.Read(reader, tableDefinitions);
                            library.localizations.Add(localization.Culture, localization);
                            break;

                        case "section":
                            Section section = Section.Read(reader, tableDefinitions);
                            section.LibraryId = library.id;
                            library.sections.Add(section);
                            break;

                        default:
                            throw new XmlException();
                        }
                        break;

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

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

            return(library);
        }
 public static Message SwitchingToPerUserPackage(SourceLineNumber sourceLineNumbers, string path)
 {
     return(Message(sourceLineNumbers, Ids.SwitchingToPerUserPackage, "Bundle switching from per-machine to per-user due to addition of per-user package '{0}'.", path));
 }
Exemplo n.º 7
0
 public static Message SingleRegIdPerProduct(SourceLineNumber sourceLineNumbers, string regid, string firstRegid, SourceLineNumber firstSourceLineNumbers)
 {
     return(Message(sourceLineNumbers, Ids.SingleRegIdPerProduct, "All of the Tag/@Regid attribute values in a package must match. The RegId '{0}' does not match the first RegId '{1}' found at: {2}.", regid, firstRegid, firstSourceLineNumbers.ToString()));
 }
Exemplo n.º 8
0
 public static Message IllegalAttributeWithoutComponent(SourceLineNumber sourceLineNumbers, string elementName, string attributeName)
 {
     return(Message(sourceLineNumbers, Ids.IllegalAttributeWithoutComponent, "The {0}/@{1} attribute cannot be specified unless the element has a component as an ancestor. A {0} that does not have a component ancestor is not installed.", elementName, attributeName));
 }
Exemplo n.º 9
0
 public static Message WebSiteAttributeUnderWebSite(SourceLineNumber sourceLineNumbers, string elementName)
 {
     return(Message(sourceLineNumbers, Ids.WebSiteAttributeUnderWebSite, "The {0}/@WebSite attribute cannot be specified when the {0} element is nested under a WebSite element.", elementName));
 }
Exemplo n.º 10
0
 public static Message DeprecatedBinaryChildElement(SourceLineNumber sourceLineNumbers, string elementName)
 {
     return(Message(sourceLineNumbers, Ids.DeprecatedBinaryChildElement, "The {0} element contains a deprecated child Binary element.  Please move the Binary element under a Fragment, Module, or Product element and set the {0}/@BinaryKey attribute to the value of the Binary/@Id attribute.", elementName));
 }
Exemplo n.º 11
0
 public static Message WebApplicationAlreadySpecified(SourceLineNumber sourceLineNumbers, string elementName)
 {
     return(Message(sourceLineNumbers, Ids.WebApplicationAlreadySpecified, "The {0} element can have at most a single WebApplication specified. This can be either through the WebApplication attribute, or through a nested WebApplication element, but not both.", elementName));
 }
Exemplo n.º 12
0
 public static Message RequiredAttributeUnderComponent(SourceLineNumber sourceLineNumbers, string elementName, string attributeName)
 {
     return(Message(sourceLineNumbers, Ids.RequiredAttributeUnderComponent, "The {0}/@{1} attribute must be specified when the element has a Component as an ancestor.", elementName, attributeName));
 }
Exemplo n.º 13
0
 public static Message OneOfAttributesRequiredUnderComponent(SourceLineNumber sourceLineNumbers, string elementName, string attributeName1, string attributeName2, string attributeName3, string attributeName4)
 {
     return(Message(sourceLineNumbers, Ids.OneOfAttributesRequiredUnderComponent, "When nested under a Component, the {0} element must have one of the following attributes specified: {1}, {2}, {3} or {4}.", elementName, attributeName1, attributeName2, attributeName3, attributeName4));
 }
Exemplo n.º 14
0
 public static Message UnexpectedAttributeWithOtherValue(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string value, string otherAttributeName, string otherValue)
 {
     return(Message(sourceLineNumbers, Ids.UnexpectedAttributeWithOtherValue, "The {0}/@{1} attribute's value, '{2}', cannot coexist with the {3} attribute's value of '{4}'.", elementName, attributeName, value, otherAttributeName, otherValue));
 }
Exemplo n.º 15
0
 public static Message IllegalName(SourceLineNumber sourceLineNumbers, string parentElement, string name)
 {
     return(Message(sourceLineNumbers, Ids.IllegalName, "The Tag/@Name attribute value, '{1}', contains invalid filename identifiers. The Tag/@Name may have defaulted from the {0}/@Name attrbute. If so, use the Tag/@Name attribute to provide a valid filename. Any character except for the follow may be used: \\ ? | > < : / * \".", parentElement, name));
 }
Exemplo n.º 16
0
 public static Message UnexpectedAttributeWithoutOtherValue(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string otherAttributeName, string otherValue)
 {
     return(Message(sourceLineNumbers, Ids.UnexpectedAttributeWithoutOtherValue, "The {0}/@{1} cannot be provided unless the {2} attribute is provided with a value of '{3}'.", elementName, attributeName, otherAttributeName, otherValue));
 }
Exemplo n.º 17
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);
        }
Exemplo n.º 18
0
        /// <summary>
        /// Parse a section from the xml.
        /// </summary>
        /// <param name="reader">XmlReader where the intermediate is persisted.</param>
        /// <param name="tableDefinitions">TableDefinitions to use in the intermediate.</param>
        /// <returns>The parsed Section.</returns>
        internal static Section Read(XmlReader reader, TableDefinitionCollection tableDefinitions)
        {
            Debug.Assert("section" == reader.LocalName);

            int         codepage = 0;
            bool        empty    = reader.IsEmptyElement;
            string      id       = null;
            SectionType type     = SectionType.Unknown;

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

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

                case "type":
                    switch (reader.Value)
                    {
                    case "bundle":
                        type = SectionType.Bundle;
                        break;

                    case "fragment":
                        type = SectionType.Fragment;
                        break;

                    case "module":
                        type = SectionType.Module;
                        break;

                    case "patchCreation":
                        type = SectionType.PatchCreation;
                        break;

                    case "product":
                        type = SectionType.Product;
                        break;

                    case "patch":
                        type = SectionType.Patch;
                        break;

                    default:
                        throw new XmlException();
                    }
                    break;
                }
            }

            if (null == id && (SectionType.Unknown != type && SectionType.Fragment != type))
            {
                throw new XmlException();
            }

            if (SectionType.Unknown == type)
            {
                throw new XmlException();
            }

            Section section = new Section(id, type, codepage);

            section.SourceLineNumbers = SourceLineNumber.CreateFromUri(reader.BaseURI);

            List <Table> tables = new List <Table>();

            if (!empty)
            {
                bool done = false;

                while (!done && reader.Read())
                {
                    switch (reader.NodeType)
                    {
                    case XmlNodeType.Element:
                        switch (reader.LocalName)
                        {
                        case "table":
                            tables.Add(Table.Read(reader, section, tableDefinitions));
                            break;

                        default:
                            throw new XmlException();
                        }
                        break;

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

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

            section.Tables = new TableIndexedCollection(tables);

            return(section);
        }
Exemplo n.º 19
0
        /// <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));
            SectionType sectionType = SectionType.Unknown;
            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;
                        sectionType = SectionType.Bundle;
                        break;

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

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

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

                    case "Product":
                        output.Type = OutputType.Product;
                        sectionType = SectionType.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(WixDataErrors.VersionMismatch(SourceLineNumber.CreateFromUri(reader.BaseURI), "wixOutput", version.ToString(), Output.CurrentVersion.ToString()));
            }

            // create a section for all the rows to belong to
            output.entrySection = new Section(null, sectionType, output.Codepage);

            // 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, output.entrySection, 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);
        }
Exemplo n.º 20
0
 public static Message ReusingCabCache(SourceLineNumber sourceLineNumbers, string cabinetName, string source)
 {
     return(Message(sourceLineNumbers, Ids.ReusingCabCache, "Reusing cabinet '{0}' from cabinet cache path: '{1}'.", cabinetName, source));
 }
Exemplo n.º 21
0
 /// <summary>
 /// Creates a row that belongs to a table.
 /// </summary>
 /// <param name="sourceLineNumbers">Original source lines for this row.</param>
 /// <param name="table">Table this row belongs to and should get its column definitions from.</param>
 /// <remarks>The compiler should use this constructor exclusively.</remarks>
 public Row(SourceLineNumber sourceLineNumbers, Table table)
     : this(sourceLineNumbers, table.Definition)
 {
     this.Table = table;
 }
Exemplo n.º 22
0
 private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args)
 {
     return(new Message(sourceLineNumber, MessageLevel.Verbose, (int)id, format, args));
 }
Exemplo n.º 23
0
        /// <summary>
        /// Creates a Row from the XmlReader.
        /// </summary>
        /// <param name="reader">Reader to get data from.</param>
        /// <param name="table">Table for this row.</param>
        /// <returns>New row object.</returns>
        internal static Row Read(XmlReader reader, Table table)
        {
            Debug.Assert("row" == reader.LocalName);

            bool             empty             = reader.IsEmptyElement;
            AccessModifier   access            = AccessModifier.Public;
            RowOperation     operation         = RowOperation.None;
            bool             redundant         = false;
            string           sectionId         = null;
            SourceLineNumber sourceLineNumbers = null;

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "access":
                    access = (AccessModifier)Enum.Parse(typeof(AccessModifier), reader.Value, true);
                    break;

                case "op":
                    operation = (RowOperation)Enum.Parse(typeof(RowOperation), reader.Value, true);
                    break;

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

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

                case "sourceLineNumber":
                    sourceLineNumbers = SourceLineNumber.CreateFromEncoded(reader.Value);
                    break;
                }
            }

            Row row = table.CreateRow(sourceLineNumbers);

            row.Access    = access;
            row.Operation = operation;
            row.Redundant = redundant;
            row.SectionId = sectionId;

            // loop through all the fields in a row
            if (!empty)
            {
                bool done  = false;
                int  field = 0;

                // loop through all the fields in a row
                while (!done && reader.Read())
                {
                    switch (reader.NodeType)
                    {
                    case XmlNodeType.Element:
                        switch (reader.LocalName)
                        {
                        case "field":
                            if (row.Fields.Length <= field)
                            {
                                if (!reader.IsEmptyElement)
                                {
                                    throw new XmlException();
                                }
                            }
                            else
                            {
                                row.fields[field].Read(reader);
                            }
                            ++field;
                            break;

                        default:
                            throw new XmlException();
                        }
                        break;

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

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

            return(row);
        }
Exemplo n.º 24
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)
        {
            bool   empty         = reader.IsEmptyElement;
            bool   createSymbols = false;
            string name          = null;
            bool   unreal        = false;
            bool   bootstrapperApplicationData = false;

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

                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();
            }

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

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

                while (!done && reader.Read())
                {
                    switch (reader.NodeType)
                    {
                    case XmlNodeType.Element:
                        switch (reader.LocalName)
                        {
                        case "columnDefinition":
                            ColumnDefinition 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(WixDataErrors.RealTableMissingPrimaryKeyColumn(SourceLineNumber.CreateFromUri(reader.BaseURI), name));
                }

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

            TableDefinition tableDefinition = new TableDefinition(name, columns, createSymbols, unreal, bootstrapperApplicationData);

            return(tableDefinition);
        }
Exemplo n.º 25
0
 public static Message IllegalCharacterInAttributeValue(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string value, Char illegalCharacter)
 {
     return(Message(sourceLineNumbers, Ids.IllegalCharacterInAttributeValue, "The {0}/@{1} attribute's value, '{2}', is invalid.  It cannot contain the character '{3}'.", elementName, attributeName, value, illegalCharacter));
 }