示例#1
0
文件: Table.cs 项目: fyodorkor/Data
        /// <summary>
        /// Creates a new row in the table.
        /// </summary>
        /// <param name="sourceLineNumbers">Original source lines for this row.</param>
        /// <param name="add">Specifies whether to only create the row or add it to the table automatically.</param>
        /// <returns>Row created in table.</returns>
        public Row CreateRow(SourceLineNumber sourceLineNumbers, bool add = true)
        {
            Row row;

            switch (this.Name)
            {
            case "BBControl":
                row = new BBControlRow(sourceLineNumbers, this);
                break;

            case "WixBundlePackage":
                row = new WixBundlePackageRow(sourceLineNumbers, this);
                break;

            case "WixBundleExePackage":
                row = new WixBundleExePackageRow(sourceLineNumbers, this);
                break;

            case "WixBundleMsiPackage":
                row = new WixBundleMsiPackageRow(sourceLineNumbers, this);
                break;

            case "WixBundleMspPackage":
                row = new WixBundleMspPackageRow(sourceLineNumbers, this);
                break;

            case "WixBundleMsuPackage":
                row = new WixBundleMsuPackageRow(sourceLineNumbers, this);
                break;

            case "Component":
                row = new ComponentRow(sourceLineNumbers, this);
                break;

            case "WixBundleContainer":
                row = new WixBundleContainerRow(sourceLineNumbers, this);
                break;

            case "Control":
                row = new ControlRow(sourceLineNumbers, this);
                break;

            case "File":
                row = new FileRow(sourceLineNumbers, this);
                break;

            case "WixBundleMsiFeature":
                row = new WixBundleMsiFeatureRow(sourceLineNumbers, this);
                break;

            case "WixBundleMsiProperty":
                row = new WixBundleMsiPropertyRow(sourceLineNumbers, this);
                break;

            case "Media":
                row = new MediaRow(sourceLineNumbers, this);
                break;

            case "WixBundlePayload":
                row = new WixBundlePayloadRow(sourceLineNumbers, this);
                break;

            case "Property":
                row = new PropertyRow(sourceLineNumbers, this);
                break;

            case "WixRelatedBundle":
                row = new WixRelatedBundleRow(sourceLineNumbers, this);
                break;

            case "WixBundleRelatedPackage":
                row = new WixBundleRelatedPackageRow(sourceLineNumbers, this);
                break;

            case "WixBundleRollbackBoundary":
                row = new WixBundleRollbackBoundaryRow(sourceLineNumbers, this);
                break;

            case "Upgrade":
                row = new UpgradeRow(sourceLineNumbers, this);
                break;

            case "WixBundleVariable":
                row = new WixBundleVariableRow(sourceLineNumbers, this);
                break;

            case "WixAction":
                row = new WixActionRow(sourceLineNumbers, this);
                break;

            case "WixApprovedExeForElevation":
                row = new WixApprovedExeForElevationRow(sourceLineNumbers, this);
                break;

            case "WixBundle":
                row = new WixBundleRow(sourceLineNumbers, this);
                break;

            case "WixBundlePackageExitCode":
                row = new WixBundlePackageExitCodeRow(sourceLineNumbers, this);
                break;

            case "WixBundlePatchTargetCode":
                row = new WixBundlePatchTargetCodeRow(sourceLineNumbers, this);
                break;

            case "WixBundleSlipstreamMsp":
                row = new WixBundleSlipstreamMspRow(sourceLineNumbers, this);
                break;

            case "WixBundleUpdate":
                row = new WixBundleUpdateRow(sourceLineNumbers, this);
                break;

            case "WixBundleCatalog":
                row = new WixBundleCatalogRow(sourceLineNumbers, this);
                break;

            case "WixChain":
                row = new WixChainRow(sourceLineNumbers, this);
                break;

            case "WixChainItem":
                row = new WixChainItemRow(sourceLineNumbers, this);
                break;

            case "WixBundlePackageCommandLine":
                row = new WixBundlePackageCommandLineRow(sourceLineNumbers, this);
                break;

            case "WixComplexReference":
                row = new WixComplexReferenceRow(sourceLineNumbers, this);
                break;

            case "WixDeltaPatchFile":
                row = new WixDeltaPatchFileRow(sourceLineNumbers, this);
                break;

            case "WixDeltaPatchSymbolPaths":
                row = new WixDeltaPatchSymbolPathsRow(sourceLineNumbers, this);
                break;

            case "WixFile":
                row = new WixFileRow(sourceLineNumbers, this);
                break;

            case "WixGroup":
                row = new WixGroupRow(sourceLineNumbers, this);
                break;

            case "WixMedia":
                row = new WixMediaRow(sourceLineNumbers, this);
                break;

            case "WixMediaTemplate":
                row = new WixMediaTemplateRow(sourceLineNumbers, this);
                break;

            case "WixMerge":
                row = new WixMergeRow(sourceLineNumbers, this);
                break;

            case "WixPayloadProperties":
                row = new WixPayloadPropertiesRow(sourceLineNumbers, this);
                break;

            case "WixProperty":
                row = new WixPropertyRow(sourceLineNumbers, this);
                break;

            case "WixSimpleReference":
                row = new WixSimpleReferenceRow(sourceLineNumbers, this);
                break;

            case "WixUpdateRegistration":
                row = new WixUpdateRegistrationRow(sourceLineNumbers, this);
                break;

            case "WixVariable":
                row = new WixVariableRow(sourceLineNumbers, this);
                break;

            default:
                row = new Row(sourceLineNumbers, this);
                break;
            }

            if (add)
            {
                this.Rows.Add(row);
            }

            return(row);
        }
示例#2
0
        /// <summary>
        /// Parses a WixStandardBootstrapperApplication element for Bundles.
        /// </summary>
        /// <param name="node">The element to parse.</param>
        private void ParseWixStandardBootstrapperApplicationElement(XElement node)
        {
            SourceLineNumber sourceLineNumbers      = Preprocessor.GetSourceLineNumbers(node);
            string           launchTarget           = null;
            string           launchTargetElevatedId = null;
            string           launchArguments        = null;
            YesNoType        launchHidden           = YesNoType.NotSet;
            string           launchWorkingDir       = null;
            string           licenseFile            = null;
            string           licenseUrl             = null;
            string           logoFile                 = null;
            string           logoSideFile             = null;
            string           themeFile                = null;
            string           localizationFile         = null;
            YesNoType        suppressOptionsUI        = YesNoType.NotSet;
            YesNoType        suppressDowngradeFailure = YesNoType.NotSet;
            YesNoType        suppressRepair           = YesNoType.NotSet;
            YesNoType        showVersion              = YesNoType.NotSet;
            YesNoType        supportCacheOnly         = YesNoType.NotSet;

            foreach (XAttribute attrib in node.Attributes())
            {
                if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace)
                {
                    switch (attrib.Name.LocalName)
                    {
                    case "LaunchTarget":
                        launchTarget = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
                        break;

                    case "LaunchTargetElevatedId":
                        launchTargetElevatedId = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
                        break;

                    case "LaunchArguments":
                        launchArguments = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
                        break;

                    case "LaunchHidden":
                        launchHidden = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
                        break;

                    case "LaunchWorkingFolder":
                        launchWorkingDir = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
                        break;

                    case "LicenseFile":
                        licenseFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
                        break;

                    case "LicenseUrl":
                        licenseUrl = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty);
                        break;

                    case "LogoFile":
                        logoFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
                        break;

                    case "LogoSideFile":
                        logoSideFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
                        break;

                    case "ThemeFile":
                        themeFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
                        break;

                    case "LocalizationFile":
                        localizationFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
                        break;

                    case "SuppressOptionsUI":
                        suppressOptionsUI = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
                        break;

                    case "SuppressDowngradeFailure":
                        suppressDowngradeFailure = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
                        break;

                    case "SuppressRepair":
                        suppressRepair = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
                        break;

                    case "ShowVersion":
                        showVersion = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
                        break;

                    case "SupportCacheOnly":
                        supportCacheOnly = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
                        break;

                    default:
                        this.Core.UnexpectedAttribute(node, attrib);
                        break;
                    }
                }
                else
                {
                    this.Core.ParseExtensionAttribute(node, attrib);
                }
            }

            this.Core.ParseForExtensionElements(node);

            if (String.IsNullOrEmpty(licenseFile) && null == licenseUrl)
            {
                this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "LicenseFile", "LicenseUrl", true));
            }

            if (!this.Core.EncounteredError)
            {
                if (!String.IsNullOrEmpty(launchTarget))
                {
                    WixBundleVariableRow row = (WixBundleVariableRow)this.Core.CreateRow(sourceLineNumbers, "WixBundleVariable");
                    row.Id    = "LaunchTarget";
                    row.Value = launchTarget;
                    row.Type  = "string";
                }

                if (!String.IsNullOrEmpty(launchTargetElevatedId))
                {
                    WixBundleVariableRow row = (WixBundleVariableRow)this.Core.CreateRow(sourceLineNumbers, "WixBundleVariable");
                    row.Id    = "LaunchTargetElevatedId";
                    row.Value = launchTargetElevatedId;
                    row.Type  = "string";
                }

                if (!String.IsNullOrEmpty(launchArguments))
                {
                    WixBundleVariableRow row = (WixBundleVariableRow)this.Core.CreateRow(sourceLineNumbers, "WixBundleVariable");
                    row.Id    = "LaunchArguments";
                    row.Value = launchArguments;
                    row.Type  = "string";
                }

                if (YesNoType.Yes == launchHidden)
                {
                    WixBundleVariableRow row = (WixBundleVariableRow)this.Core.CreateRow(sourceLineNumbers, "WixBundleVariable");
                    row.Id    = "LaunchHidden";
                    row.Value = "yes";
                    row.Type  = "string";
                }


                if (!String.IsNullOrEmpty(launchWorkingDir))
                {
                    WixBundleVariableRow row = (WixBundleVariableRow)this.Core.CreateRow(sourceLineNumbers, "Variable");
                    row.Id    = "LaunchWorkingFolder";
                    row.Value = launchWorkingDir;
                    row.Type  = "string";
                }

                if (!String.IsNullOrEmpty(licenseFile))
                {
                    WixVariableRow wixVariableRow = (WixVariableRow)this.Core.CreateRow(sourceLineNumbers, "WixVariable");
                    wixVariableRow.Id    = "WixStdbaLicenseRtf";
                    wixVariableRow.Value = licenseFile;
                }

                if (null != licenseUrl)
                {
                    WixVariableRow wixVariableRow = (WixVariableRow)this.Core.CreateRow(sourceLineNumbers, "WixVariable");
                    wixVariableRow.Id    = "WixStdbaLicenseUrl";
                    wixVariableRow.Value = licenseUrl;
                }

                if (!String.IsNullOrEmpty(logoFile))
                {
                    WixVariableRow wixVariableRow = (WixVariableRow)this.Core.CreateRow(sourceLineNumbers, "WixVariable");
                    wixVariableRow.Id    = "WixStdbaLogo";
                    wixVariableRow.Value = logoFile;
                }

                if (!String.IsNullOrEmpty(logoSideFile))
                {
                    WixVariableRow wixVariableRow = (WixVariableRow)this.Core.CreateRow(sourceLineNumbers, "WixVariable");
                    wixVariableRow.Id    = "WixStdbaLogoSide";
                    wixVariableRow.Value = logoSideFile;
                }

                if (!String.IsNullOrEmpty(themeFile))
                {
                    WixVariableRow wixVariableRow = (WixVariableRow)this.Core.CreateRow(sourceLineNumbers, "WixVariable");
                    wixVariableRow.Id    = "WixStdbaThemeXml";
                    wixVariableRow.Value = themeFile;
                }

                if (!String.IsNullOrEmpty(localizationFile))
                {
                    WixVariableRow wixVariableRow = (WixVariableRow)this.Core.CreateRow(sourceLineNumbers, "WixVariable");
                    wixVariableRow.Id    = "WixStdbaThemeWxl";
                    wixVariableRow.Value = localizationFile;
                }

                if (YesNoType.Yes == suppressOptionsUI || YesNoType.Yes == suppressDowngradeFailure || YesNoType.Yes == suppressRepair || YesNoType.Yes == showVersion || YesNoType.Yes == supportCacheOnly)
                {
                    Row row = this.Core.CreateRow(sourceLineNumbers, "WixStdbaOptions");
                    if (YesNoType.Yes == suppressOptionsUI)
                    {
                        row[0] = 1;
                    }

                    if (YesNoType.Yes == suppressDowngradeFailure)
                    {
                        row[1] = 1;
                    }

                    if (YesNoType.Yes == suppressRepair)
                    {
                        row[2] = 1;
                    }

                    if (YesNoType.Yes == showVersion)
                    {
                        row[3] = 1;
                    }

                    if (YesNoType.Yes == supportCacheOnly)
                    {
                        row[4] = 1;
                    }
                }
            }
        }