Example #1
0
        /// <summary>
        /// Checks whether specified app (from catalog) matches current app (from system)
        /// </summary>
        /// <param name="app">Catalog app</param>
        /// <returns></returns>
        public bool MatchesAppPackage(AppPackage app)
        {
            try
            {
                Regex check = new Regex(app.MatchRegexp, RegexOptions.IgnoreCase);
                bool regmatch = check.IsMatch(this.DisplayName);

                // Not a match for the given regular expression
                if (!regmatch) return false;

                // Is there any minimum version specified?
                if (app.MinimumVersion != null)
                {
                    int miniVersion = int.Parse(app.MinimumVersion);
                    if (this.MajorVersionNumber < miniVersion) return false; // does not meet requirement
                }

                // Any maximum version specified
                if (app.MaximumVersion != null)
                {
                    int maxiVersion = int.Parse(app.MaximumVersion);
                    if (this.MajorVersionNumber > maxiVersion) return false; // does not meet requirement
                }

            }

            catch (Exception e)
            {
                MessageBox.Show(this.DisplayName+" => "+e.ToString());
            }
            return true;
        }
Example #2
0
        /// <summary>
        /// Checks in the catalog of supported apps for whether the application is supported
        /// </summary>
        public bool CheckSupport()
        {
            ArrayList catalog = AppCatalog.GetSupportedApps();
            Supported = false;
            foreach (AppPackage app in catalog)
            {
                if (this.MatchesAppPackage(app))
                {
                    Supported = true;
                    package = app;
                    Notes = app.Notes;
                    break;
                }
            }

            return Supported;
        }
Example #3
0
        public static ArrayList GetSupportedApps(bool reload=false)
        {
            if (!reload && SupportedAppCatalog != null) return SupportedAppCatalog;
            SupportedAppCatalog = new ArrayList();

            // Create XML Document
            try
            {
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load("AppCatalog.xml");

                // Get Application nodes
                XmlNodeList apps = xmlDoc.GetElementsByTagName("App");
                foreach (XmlNode appNode in apps)
                {
                    // Create instance and initialize values from XML
                    var app = new AppPackage()
                    {
                        Name = appNode.Attributes["Name"] == null ? "" : appNode.Attributes["Name"].Value,
                        UniqueID = appNode.Attributes["UniqueID"] == null ? "" : appNode.Attributes["UniqueID"].Value,
                        MatchRegexp = appNode.Attributes["MatchRegexp"] == null ? "" : appNode.Attributes["MatchRegexp"].Value,
                        MinimumVersion = appNode.Attributes["MinimumVersion"] == null ? null : appNode.Attributes["MinimumVersion"].Value,
                        MaximumVersion = appNode.Attributes["MaximumVersion"] == null ? null : appNode.Attributes["MaximumVersion"].Value,
                        Notes = appNode.Attributes["Notes"] == null ? "" : appNode.Attributes["Notes"].Value
                    };
                    app.RegistryKeys = new ArrayList();
                    app.Folders = new ArrayList();

                    // Read registry keys
                    foreach (XmlNode node in appNode.ChildNodes)
                    {
                        if (node.Name == "RegistryKeys")
                        {
                            // We're checking out the registry keys; so browse the node
                            foreach (XmlNode keyNode in node.ChildNodes)
                            {
                                RegKey key = new RegKey()
                                {
                                    Root = keyNode.Attributes["Root"].Value,
                                    Key = keyNode.InnerText
                                };
                                key.App = app;
                                app.RegistryKeys.Add(key);
                            }
                        }
                        else if (node.Name == "Folders")
                        {
                            // We're checking out the folders; so browse the node
                            foreach (XmlNode folderNode in node.ChildNodes)
                            {
                                Folder folder = new Folder()
                                {
                                    Root = folderNode.Attributes["Root"].Value,
                                    ID = folderNode.Attributes["ID"].Value,
                                    Path = folderNode.InnerText
                                };
                                folder.App = app;
                                app.Folders.Add(folder);
                            }

                        }

                    }

                    SupportedAppCatalog.Add(app);
                }

                return SupportedAppCatalog;
            }
            catch
            {
                return null;
            }
        }