Beispiel #1
0
 void IHelpService.RemoveLocalContext(IHelpService localContext)
 {
     if ((_SubContextList != null) && (_SubContextList.IndexOf(localContext) != -1))
     {
         _SubContextList.Remove(localContext);
         if (_Context != null)
         {
             NativeMethods.ThrowOnFailure(_Context.RemoveSubcontext(((HelpService)localContext)._Cookie));
         }
         ((HelpService)localContext)._ParentService = null;
     }
 }
        /// <include file='doc\HelpService.uex' path='docs/doc[@for="HelpService.Dispose"]/*' />
        /// <devdoc>
        ///     Disposes this object.
        /// </devdoc>
        public virtual void Dispose()
        {
            if (subContextList != null && subContextList.Count > 0)
            {
                foreach (HelpService hs in subContextList)
                {
                    hs.parentService = null;
                    if (context != null)
                    {
                        context.RemoveSubcontext(hs.cookie);
                    }
                    hs.Dispose();
                }
                subContextList = null;
            }

            if (parentService != null)
            {
                IHelpService parent = parentService;
                parentService = null;
                parent.RemoveLocalContext(this);
            }

            if (provider != null)
            {
                IDesignerHost host = (IDesignerHost)provider.GetService(typeof(IDesignerHost));
                if (host != null)
                {
                    host.Activated -= new EventHandler(this.OnDesignerActivate);
                }
                provider = null;
            }
            if (context != null)
            {
                System.Runtime.InteropServices.Marshal.ReleaseComObject(context);
                context = null;
            }
            this.cookie = 0;
        }
Beispiel #3
0
        /// <devdoc>
        ///     Disposes this object.
        /// </devdoc>
        void IDisposable.Dispose()
        {
            if (subContextList != null && subContextList.Count > 0)
            {
                foreach (HelpService hs in subContextList)
                {
                    hs.parentService = null;
                    if (context != null)
                    {
                        try {
                            // Here we don't want to check for the return code because we are
                            // disposing the object, so there is nothing we can do in case of error.
                            context.RemoveSubcontext(hs.cookie);
                        } catch (COMException) { /* do nothing */ }
                    }
                    ((IDisposable)hs).Dispose();
                }
                subContextList = null;
            }

            if (parentService != null)
            {
                IHelpService parent = parentService;
                parentService = null;
                parent.RemoveLocalContext(this);
            }

            if (provider != null)
            {
                provider = null;
            }
            if (context != null)
            {
                System.Runtime.InteropServices.Marshal.ReleaseComObject(context);
                context = null;
            }
            this.cookie = 0;
        }