Example #1
0
        /// <summary>
        /// Constructs a plug-in domain event with a installed plug-in
        /// </summary>
        /// <param name="plug-in">The plug-in reference</param>
        public PluginDomainEventBase
        (
            InstalledPlugin plugin
        )
        {
            Validate.IsNotNull(plugin);

            this.Plugin = plugin;
        }
Example #2
0
        protected internal InstalledPluginTypeInfo(InstalledPlugin installedPlugin, Type type)
        {
            Validate.IsNotNull(installedPlugin);
            Validate.IsNotNull(type);

            this.LookupKey       = new EntityKeyGenerator().GenerateKey();
            this.InstalledPlugin = installedPlugin;
            this.TypeName        = type.Name;
            this.TypeFullName    = type.FullName;

            if (type.BaseType != null)
            {
                this.BaseTypeName     = type.BaseType.Name;
                this.BaseTypeFullName = type.BaseType.FullName;
            }
        }
Example #3
0
        /// <summary>
        /// Automatically installs the plug-ins specified
        /// </summary>
        /// <param name="plugins">The plugins to install</param>
        public void AutoInstallPlugins(params IPlugin[] plugins)
        {
            var namesOfPluginsInstalled = new List <string>();

            foreach (var plugin in plugins)
            {
                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);
                    }
                }
            }
        }