示例#1
0
        private void StartExtensions()
        {
            if (PluginRegistry == null || PluginRegistry.Count == 0)
            {
                Log.Info("No plugins loaded, skipping initalization.");
                return;
            }

            Log.Info("Initializing extensions...");

            for (var i = 0; i < PluginRegistry.Count; i++)
            {
                var pluginHost = PluginRegistry[i];

                try
                {
                    var pluginInfo   = PluginRegistry.GetPluginInfoByName(pluginHost.Manifest.FriendlyName);
                    var isLastPlugin = (i == PluginRegistry.Count - 1);

                    pluginHost.Instance.Initialize(this, pluginHost.Manifest.IPCIdentifier);
                    PluginInitialized?.Invoke(this, new PluginInitializationEventArgs(pluginInfo, isLastPlugin));

                    Log.Info($"Plugin {pluginHost.Manifest.FriendlyName} initialized");
                }
                catch (Exception ex)
                {
                    Log.Error($"Plugin {pluginHost.Manifest.FriendlyName} failed to initialize. Exception has been caught, see the log for details.");
                    Log.ExceptionSilent(ex);
                }
            }

            Log.Info("Extensions initialized.");
        }