/// <summary>
        /// Loads the fabricator data from disk.
        /// </summary>
        /// <param name="path">Path to load the facbricator information from.</param>
        public override void Open(string path)
        {
            Assembly[]        assemblies = new Assembly[] { Assembly.GetExecutingAssembly() };
            Wix.CodeDomReader reader     = new Wix.CodeDomReader(assemblies);

            IA.IsolatedApp isolatedApp = reader.Load(path) as IA.IsolatedApp;
            if (null == isolatedApp)
            {
                throw new ApplicationException("Failed to load isolated app data file.");
            }

            this.description     = null;
            this.packageId       = Guid.Empty;
            this.manufacturer    = null;
            this.appId           = Guid.Empty;
            this.appVersion      = null;
            this.updateUrl       = null;
            this.details         = null;
            this.name            = null;
            this.source          = null;
            this.entryPoint      = null;
            this.iconPath        = null;
            this.previousFeedUrl = null;

            foreach (Wix.ISchemaElement child in isolatedApp.Children)
            {
                if (child is IA.Package)
                {
                    foreach (Wix.ISchemaElement grandchild in ((IA.Package)child).Children)
                    {
                        if (grandchild is IA.Description)
                        {
                            this.description = ((IA.Description)grandchild).Content;
                        }
                        else if (grandchild is IA.Feed)
                        {
                            if (((IA.Feed)grandchild).Content != null)
                            {
                                this.updateUrl = new Uri(((IA.Feed)grandchild).Content);
                            }
                        }
                        else if (grandchild is IA.UpdateRate)
                        {
                            if (((IA.UpdateRate)grandchild).Content != 0)
                            {
                                this.updateRate = Convert.ToInt32(((IA.UpdateRate)grandchild).Content);
                            }
                        }
                        else if (grandchild is IA.Icon)
                        {
                        }
                        else if (grandchild is IA.Id)
                        {
                            if (((IA.Id)grandchild).Content != null)
                            {
                                this.packageId = new Guid(((IA.Id)grandchild).Content);
                            }
                        }
                        else if (grandchild is IA.Manufacturer)
                        {
                            this.manufacturer = ((IA.Manufacturer)grandchild).Content;
                        }
                        else if (grandchild is IA.Version)
                        {
                            if (((IA.Version)grandchild).Content != null)
                            {
                                this.appVersion = new Version(((IA.Version)grandchild).Content);
                            }
                        }
                    }
                }
                else if (child is IA.Application)
                {
                    foreach (Wix.ISchemaElement grandchild in ((IA.Application)child).Children)
                    {
                        if (grandchild is IA.Details)
                        {
                            this.details = ((IA.Details)grandchild).Content;
                        }
                        else if (grandchild is IA.EntryPoint)
                        {
                            this.entryPoint = ((IA.EntryPoint)grandchild).Content;
                        }
                        else if (grandchild is IA.Icon)
                        {
                            this.iconPath = ((IA.Icon)grandchild).Content;
                        }
                        else if (grandchild is IA.Id)
                        {
                            this.appId = new Guid(((IA.Id)grandchild).Content);
                        }
                        else if (grandchild is IA.Name)
                        {
                            this.name = ((IA.Name)grandchild).Content;
                        }
                        else if (grandchild is IA.Source)
                        {
                            if (((IA.Source)grandchild).Content != null)
                            {
                                string expandedSource = System.Environment.ExpandEnvironmentVariables(((IA.Source)grandchild).Content);
                                this.source = Path.GetFullPath(expandedSource);
                            }
                        }
                    }
                }
                else if (child is IA.PreviousFeed)
                {
                    if (((IA.PreviousFeed)child).Content != null)
                    {
                        string expandedUrl = System.Environment.ExpandEnvironmentVariables(((IA.PreviousFeed)child).Content);
                        this.previousFeedUrl = new Uri(expandedUrl);
                    }
                }
            }

            if (this.entryPoint != null)
            {
                if (this.source != null)
                {
                    string fullPath = Path.Combine(this.source, this.entryPoint);
                    this.entryPointVersionInfo = FileVersionInfo.GetVersionInfo(fullPath);
                }
            }

            if (this.Opened != null)
            {
                this.Opened(this, new EventArgs());
            }
        }
예제 #2
0
        /// <summary>
        /// Loads the package builder data from disk.
        /// </summary>
        /// <param name="path">Path to load the builder information from.</param>
        public override void Open(string path)
        {
            Assembly[]        assemblies = new Assembly[] { Assembly.GetExecutingAssembly() };
            Wix.CodeDomReader reader     = new Wix.CodeDomReader(assemblies);

            OA.OfficeAddin officeAddin = reader.Load(path) as OA.OfficeAddin;
            if (null == officeAddin)
            {
                throw new ApplicationException("Failed to load office addin data file.");
            }

            foreach (Wix.ISchemaElement child in officeAddin.Children)
            {
                if (child is OA.Package)
                {
                    foreach (Wix.ISchemaElement grandchild in ((OA.Package)child).Children)
                    {
                        if (grandchild is OA.Description)
                        {
                            this.description = ((OA.Description)grandchild).Content;
                        }
                        else if (grandchild is OA.Feed)
                        {
                            if (((OA.Feed)grandchild).Content != null)
                            {
                                this.updateUrl = new Uri(((OA.Feed)grandchild).Content);
                            }
                        }
                        else if (grandchild is OA.UpdateRate)
                        {
                            if (((OA.UpdateRate)grandchild).Content != 0)
                            {
                                this.updateRate = Convert.ToInt32(((OA.UpdateRate)grandchild).Content);
                            }
                        }
                        else if (grandchild is OA.Icon)
                        {
                        }
                        else if (grandchild is OA.Id)
                        {
                            if (((OA.Id)grandchild).Content != null)
                            {
                                this.packageId = new Guid(((OA.Id)grandchild).Content);
                            }
                        }
                        else if (grandchild is OA.Manufacturer)
                        {
                            this.manufacturer = ((OA.Manufacturer)grandchild).Content;
                        }
                        else if (grandchild is OA.Version)
                        {
                            if (((OA.Version)grandchild).Content != null)
                            {
                                this.appVersion = new Version(((OA.Version)grandchild).Content);
                            }
                        }
                    }
                }
                else if (child is OA.Application)
                {
                    foreach (Wix.ISchemaElement grandchild in ((OA.Application)child).Children)
                    {
                        if (grandchild is OA.Details)
                        {
                            this.details = ((OA.Details)grandchild).Content;
                        }
                        else if (grandchild is OA.EntryPoint)
                        {
                            this.entryPoint = ((OA.EntryPoint)grandchild).Content;
                        }
                        else if (grandchild is OA.ExtendsApplication)
                        {
                            OfficeApplications extendedApp;
                            switch (((OA.ExtendsApplication)grandchild).Content)
                            {
                            case OA.SupportedOfficeApplications.Excel2003:
                                extendedApp = OfficeApplications.Excel2003;
                                break;

                            case OA.SupportedOfficeApplications.Outlook2003:
                                extendedApp = OfficeApplications.Outlook2003;
                                break;

                            case OA.SupportedOfficeApplications.PowerPoint2003:
                                extendedApp = OfficeApplications.PowerPoint2003;
                                break;

                            case OA.SupportedOfficeApplications.Word2003:
                                extendedApp = OfficeApplications.Word2003;
                                break;

                            default:
                                throw new ArgumentException("Unexpected application in data file.", "ExtendsApplication");
                            }

                            if (!this.extendedOfficeApplications.Contains(extendedApp))
                            {
                                this.extendedOfficeApplications.Add(extendedApp);
                            }
                        }
                        else if (grandchild is OA.Icon)
                        {
                            this.iconPath = ((OA.Icon)grandchild).Content;
                        }
                        else if (grandchild is OA.Id)
                        {
                            this.appId = new Guid(((OA.Id)grandchild).Content);
                        }
                        else if (grandchild is OA.Name)
                        {
                            this.name = ((OA.Name)grandchild).Content;
                        }
                        else if (grandchild is OA.Source)
                        {
                            if (((OA.Source)grandchild).Content != null)
                            {
                                string expandedSource = System.Environment.ExpandEnvironmentVariables(((OA.Source)grandchild).Content);
                                this.source = Path.GetFullPath(expandedSource);
                            }
                        }
                    }
                }
                else if (child is OA.PreviousFeed)
                {
                    if (((OA.PreviousFeed)child).Content != null)
                    {
                        string expandedUrl = System.Environment.ExpandEnvironmentVariables(((OA.PreviousFeed)child).Content);
                        this.previousFeedUrl = new Uri(expandedUrl);
                    }
                }
            }

            if (this.entryPoint != null)
            {
                if (this.source != null)
                {
                    string fullPath = Path.Combine(this.source, this.entryPoint);
                    this.entryPointVersionInfo = FileVersionInfo.GetVersionInfo(fullPath);
                }
            }

            if (this.Opened != null)
            {
                this.Opened(this, new EventArgs());
            }
        }