private void UnadviseNotifySink()
        {
            Debug.Assert(_cookie != UnsafeNativeMethods.TF_INVALID_COOKIE, "Cookie is not set.");

            UnsafeNativeMethods.ITfSource source = _ipp.Value as UnsafeNativeMethods.ITfSource;

            source.UnadviseSink(_cookie);

            _cookie = UnsafeNativeMethods.TF_INVALID_COOKIE;
        }
Exemple #2
0
        /// <summary>
        ///     Unadvise the notify sink of the compartment update.
        /// </summary>
        internal void UnadviseNotifySink()
        {
            Debug.Assert(_cookie != UnsafeNativeMethods.TF_INVALID_COOKIE, "cookie is not set.");

            UnsafeNativeMethods.ITfCompartment compartment = GetITfCompartment();
            if (compartment == null)
            {
                return;
            }

            UnsafeNativeMethods.ITfSource source = compartment as UnsafeNativeMethods.ITfSource;
            source.UnadviseSink(_cookie);
            _cookie = UnsafeNativeMethods.TF_INVALID_COOKIE;

            Marshal.ReleaseComObject(compartment);
            Marshal.ReleaseComObject(source);
        }
Exemple #3
0
        private object OnUnregisterTextStore(object arg)
        {
            if (this._threadManager == null || this._threadManager.Value == null)
            {
                return(null);
            }
            SecurityPermission securityPermission = new SecurityPermission(SecurityPermissionFlag.UnmanagedCode);
            TextStore          textStore          = (TextStore)arg;

            if (textStore.ThreadFocusCookie != -1)
            {
                UnsafeNativeMethods.ITfSource tfSource = this._threadManager.Value as UnsafeNativeMethods.ITfSource;
                tfSource.UnadviseSink(textStore.ThreadFocusCookie);
                textStore.ThreadFocusCookie = -1;
            }
            UnsafeNativeMethods.ITfContext tfContext;
            textStore.DocumentManager.GetBase(out tfContext);
            if (tfContext != null)
            {
                if (textStore.EditSinkCookie != -1)
                {
                    UnsafeNativeMethods.ITfSource tfSource = tfContext as UnsafeNativeMethods.ITfSource;
                    tfSource.UnadviseSink(textStore.EditSinkCookie);
                    textStore.EditSinkCookie = -1;
                }
                Marshal.ReleaseComObject(tfContext);
            }
            securityPermission.Assert();
            try
            {
                textStore.DocumentManager.Pop(UnsafeNativeMethods.PopFlags.TF_POPF_ALL);
            }
            finally
            {
                CodeAccessPermission.RevertAssert();
            }
            Marshal.ReleaseComObject(textStore.DocumentManager);
            textStore.DocumentManager = null;
            this._registeredtextstorecount--;
            if (this._isDispatcherShutdownFinished && this._registeredtextstorecount == 0)
            {
                this.DeactivateThreadManager();
            }
            return(null);
        }
Exemple #4
0
        internal static void StopTransitoryExtension(TextStore textstore)
        {
            UnsafeNativeMethods.ITfCompartmentMgr tfCompartmentMgr = textstore.DocumentManager as UnsafeNativeMethods.ITfCompartmentMgr;
            if (textstore.TransitoryExtensionSinkCookie != -1)
            {
                UnsafeNativeMethods.ITfSource tfSource = textstore.DocumentManager as UnsafeNativeMethods.ITfSource;
                if (tfSource != null)
                {
                    tfSource.UnadviseSink(textstore.TransitoryExtensionSinkCookie);
                }
                textstore.TransitoryExtensionSinkCookie = -1;
            }
            Guid guid_COMPARTMENT_TRANSITORYEXTENSION = UnsafeNativeMethods.GUID_COMPARTMENT_TRANSITORYEXTENSION;

            UnsafeNativeMethods.ITfCompartment tfCompartment;
            tfCompartmentMgr.GetCompartment(ref guid_COMPARTMENT_TRANSITORYEXTENSION, out tfCompartment);
            object obj = 0;

            tfCompartment.SetValue(0, ref obj);
            Marshal.ReleaseComObject(tfCompartment);
        }