SEModAPIExtensions.API.PluginManager.UnloadPlugin C# (CSharp) Method

UnloadPlugin() public method

public UnloadPlugin ( System.Guid key ) : void
key System.Guid
return void
        public void UnloadPlugin( Guid key )
        {
            IPlugin plugin;
            //Skip if the plugin doesn't exist
            if ( !Plugins.TryGetValue( key, out plugin ) )
                return;

            //Skip if the plugin is already unloaded
            if ( !PluginStates.ContainsKey( key ) )
                return;

            ApplicationLog.BaseLog.Info( "Unloading plugin '{0}'", key );

            try
            {
                MethodInfo initMethod = plugin.GetType( ).GetMethod( "Shutdown" );
                initMethod.Invoke( plugin, new object[ ] { } );
            }
            catch ( Exception ex )
            {
                ApplicationLog.BaseLog.Error( ex );
            }

            _pluginAssemblies.Remove( key );
            PluginStates.Remove( key );
            Plugins.Remove( key );
        }