Example #1
0
        private void OnPlugInActivated(object?sender, PlugInEventArgs e)
        {
            if (!this.IsEventRelevant(e))
            {
                return;
            }

            this.BeforeActivatePlugInType(e.PlugInType);

            var plugIn = this.FindActivePlugin(e.PlugInType);

            if (plugIn != null)
            {
                return;
            }

            plugIn = this.FindKnownPlugin(e.PlugInType);
            if (plugIn is null)
            {
                return;
            }

            this.LockSlim.EnterWriteLock();
            try
            {
                this.ActivatePlugIn(plugIn);
            }
            finally
            {
                this.LockSlim.ExitWriteLock();
            }
        }
Example #2
0
        private void OnPlugInActivated(object sender, PlugInEventArgs e)
        {
            if (!this.IsEventRelevant(e))
            {
                return;
            }

            var plugIn = this.FindActivePlugin(e.PlugInType);

            if (plugIn != null)
            {
                return;
            }

            plugIn = this.FindKnownPlugin(e.PlugInType);
            if (plugIn == null)
            {
                throw new ArgumentException($"Unknown plugin {e.PlugInType}.", nameof(e));
            }

            this.LockSlim.EnterWriteLock();
            try
            {
                this.ActivatePlugIn(plugIn);
            }
            finally
            {
                this.LockSlim.ExitWriteLock();
            }
        }
Example #3
0
        private void OnPlugInDeactivated(object sender, PlugInEventArgs e)
        {
            if (!this.IsEventRelevant(e))
            {
                return;
            }

            var plugIn = this.FindActivePlugin(e.PlugInType);

            if (plugIn == null)
            {
                return;
            }

            this.LockSlim.EnterWriteLock();
            try
            {
                this.DeactivatePlugIn(plugIn);
            }
            finally
            {
                this.LockSlim.ExitWriteLock();
            }
        }
Example #4
0
 private bool IsEventRelevant(PlugInEventArgs e) => typeof(TPlugIn).IsAssignableFrom(e.PlugInType);