示例#1
0
        /// <summary>
        /// Automatically installs any new plug-ins that are found
        /// </summary>
        public void AutoInstallPlugins()
        {
            var allPlugins = _pluginRepository.GetAllPlugins();

            AutoInstallPlugins(allPlugins.ToArray());
        }
示例#2
0
        /// <summary>
        /// Automatically installs any new plug-ins that are found
        /// </summary>
        public void AutoInstallPlugins()
        {
            var namesOfPluginsInstalled = new List <string>();
            var allPlugins = _pluginRepository.GetAllPlugins();

            foreach (var plugin in allPlugins.ToList())
            {
                var pluginName = plugin.Name;

                var nameFound = namesOfPluginsInstalled.Contains
                                (
                    pluginName
                                );

                if (false == nameFound)
                {
                    var isRegistered = _installationRepository.IsPluginInstalled
                                       (
                        pluginName
                                       );

                    if (isRegistered)
                    {
                        var installation = _installationRepository.GetInstallation
                                           (
                            pluginName
                                           );

                        if (installation.CompareVersions(plugin) != 0)
                        {
                            var fromVersion = new Version
                                              (
                                installation.PluginVersion
                                              );

                            plugin.Upgrade(fromVersion);
                            installation.UpdatePluginDetails(plugin);

                            _installationRepository.UpdateInstallation
                            (
                                installation
                            );
                        }
                    }
                    else
                    {
                        var installedPlugin = InstalledPlugin.CreateInstalledPlugin
                                              (
                            plugin
                                              );

                        plugin.Install();

                        _installationRepository.AddInstallation
                        (
                            installedPlugin
                        );

                        namesOfPluginsInstalled.Add
                        (
                            pluginName
                        );
                    }
                }
            }
        }