Example #1
0
        /// <summary>
        /// Called when the Shell package has been initialized.
        /// </summary>
        /// <param name="package">The shell package</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="package"/> is null.</exception>
        /// <exception cref="InvalidOperationException">Thrown if a different <paramref name="package"/> has already reported being initialized.</exception>
        public void PackageInitialized(ShellPackage package)
        {
            if (package == null)
            {
                throw new ArgumentNullException("package");
            }

            ShellLock.WithWriterLock(() =>
            {
                if (this.package != null)
                {
                    if (this.package == package)
                    {
                        return;
                    }

                    throw new InvalidOperationException(
                        "Multiple packages appear to be attempting to activate the shell.");
                }

                this.package = package;

                UpdateShellActivationWithWriterLockHeld();
            });
        }
Example #2
0
        /// <summary>
        /// Called when the Shell Add-In has been disconnected.
        /// </summary>
        public void AddInDisconnected()
        {
            ShellLock.WithWriterLock(() =>
            {
                addInHandler = null;

                UpdateShellActivationWithWriterLockHeld();
            });
        }
Example #3
0
        /// <summary>
        /// Called when the Shell package has been disposed.
        /// </summary>
        public void PackageDisposed()
        {
            ShellLock.WithWriterLock(() =>
            {
                package = null;

                UpdateShellActivationWithWriterLockHeld();
            });
        }
Example #4
0
 internal void InvokeHook(HookAccessor accessor)
 {
     ShellLock.WithReaderLock(() =>
     {
         if (holder != null)
         {
             holder.InvokeHook(accessor);
         }
     });
 }
Example #5
0
        /// <summary>
        /// Called when the Shell Add-In has been connected.
        /// </summary>
        /// <param name="addInHandler">The add-in handler.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="addInHandler"/> is null.</exception>
        /// <exception cref="InvalidOperationException">Thrown if a different <paramref name="addInHandler"/> has already reported being connected.</exception>
        public void AddInConnected(ShellAddInHandler addInHandler)
        {
            if (addInHandler == null)
            {
                throw new ArgumentNullException("addInHandler");
            }

            ShellLock.WithWriterLock(() =>
            {
                if (this.addInHandler != null)
                {
                    if (this.addInHandler == addInHandler)
                    {
                        return;
                    }

                    throw new InvalidOperationException("Multiple add-in handlers appear to be attempting to activate the shell.");
                }

                this.addInHandler = addInHandler;

                UpdateShellActivationWithWriterLockHeld();
            });
        }