Exemplo n.º 1
0
        /// <summary>
        /// Starts a module by searching for a matching token
        /// </summary>
        /// <param name="moduleInfo">The ModuleInfo for the module to start</param>
        public VModule StartModule(ModuleInfo moduleInfo, bool exactlyMatchVersions = false)
        {
            VModule startedModule = null;

            foreach (AddInToken token in allAddinTokens)
            {
                if (token.Name.Equals(moduleInfo.BinaryName()) &&
                    (!exactlyMatchVersions || CompareModuleVersions(moduleInfo.GetDesiredVersion(), Utils.GetHomeOSUpdateVersion(Utils.GetAddInConfigFilepath(moduleInfo.BinaryName()), logger))))
                {
                    if (startedModule != null)
                    {
                        logger.Log("WARNING: Found multiple matching tokens for " + moduleInfo.ToString());
                        continue;
                    }

                    try
                    {
                        startedModule = StartModule(moduleInfo, token);
                    }
                    catch (Exception exception)
                    {
                        logger.Log("Could not start module {0}: {1}", moduleInfo.ToString(), exception.ToString());
                        return null;
                    }
                }
            }

            //we ran something, lets return it
            if (startedModule != null)
                return startedModule;

            //we didn't run anything.
            //if we were doing exact match on versions, this could be because we didn't find an exact match
            if (exactlyMatchVersions)
            {
                logger.Log("No exact-match-version token found for Module: Binary name: " + moduleInfo.BinaryName() + ", App Name: " + moduleInfo.AppName() + ", Version: " + moduleInfo.GetDesiredVersion());

              
                Version versionRep = new Version(GetVersionFromRep(Settings.RepositoryURIs, moduleInfo.BinaryName()));
                Version versionLocal = new Version(Utils.GetHomeOSUpdateVersion((Utils.GetAddInConfigFilepath(moduleInfo.BinaryName())), logger));

                logger.Log("The latest version for {0} on the repository: {1}", moduleInfo.BinaryName(), versionRep.ToString());
                logger.Log("The version for {0} in the local AddIn dir: {1}", moduleInfo.BinaryName(), versionLocal.ToString()); 

                if (versionRep.CompareTo(versionLocal) > 0)
                {
                    logger.Log("The latest version on the repository ({0}) > local version ({1}) in AddIn for {2} - the latest from the rep will be downloaded!", versionRep.ToString(), versionLocal.ToString(), moduleInfo.BinaryName());

                    //try to get an exact match from the homestore
                    GetAddInFromRep(moduleInfo);

                }
                //maybe, we got the right version, maybe we didn't; in any case, lets now run what we can find, without being strict about version numbers
                return StartModule(moduleInfo, false);
            }
            else
            {
                logger.Log("No matching token at all found for Module: Binary name: " + moduleInfo.BinaryName() + ", App Name: " + moduleInfo.AppName() + ", Version: " + moduleInfo.GetDesiredVersion());
                return null;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Starts a module by searching for a matching token
        /// </summary>
        /// <param name="moduleInfo">The ModuleInfo for the module to start</param>
        public VModule StartModule(ModuleInfo moduleInfo, bool exactlyMatchVersions = false)
        {
            VModule startedModule = null;

            foreach (AddInToken token in allAddinTokens)
            {
                if (token.Name.Equals(moduleInfo.BinaryName()) &&
                    (!exactlyMatchVersions || CompareModuleVersions(moduleInfo.GetVersion(), GetHomeOSUpdateVersion(GetAddInConfigFilepath(moduleInfo.BinaryName())))))
                {
                    if (startedModule != null)
                    {
                        logger.Log("WARNING: Found multiple matching tokens for " + moduleInfo.ToString());
                        continue;
                    }

                    try
                    {
                        startedModule = StartModule(moduleInfo, token);
                    }
                    catch (Exception exception)
                    {
                        logger.Log("Could not start module {0}: {1}", moduleInfo.ToString(), exception.ToString());
                        return null;
                    }
                }
            }

            //we ran something, lets return it
            if (startedModule != null)
                return startedModule;

            //we didn't run anything.
            //if we were doing exact match on versions, this could be because we didn't find an exact match
            if (exactlyMatchVersions)
            {
                logger.Log("No exact-match-version token found for Module: Binary name: " + moduleInfo.BinaryName() + ", App Name: " + moduleInfo.AppName() + ", Version: " + moduleInfo.GetVersion());

                //try to get an exact match from the homestore
                GetAddInFromRep(moduleInfo);

                //maybe, we got the right version, maybe we didn't; in any case, lets now run what we can find, without being strict about version numbers
                return StartModule(moduleInfo, false);
            }
            else
            {
                logger.Log("No matching token at all found for Module: Binary name: " + moduleInfo.BinaryName() + ", App Name: " + moduleInfo.AppName() + ", Version: " + moduleInfo.GetVersion());
                return null;
            }
        }