Exemple #1
0
        //
        //////////////////////////////////////////////////////////////

        void IOleAdviseSink.OnRename(OleInterop.IMoniker pmk)
        {
            if (null != oleSink)
            {
                oleSink.OnRename(pmk);
            }
            else
            {
                // TODO: Use the IMoniker converter when ready.
                bclSink.OnRename(null);
            }
        }
Exemple #2
0
            /// <summary>
            /// Obtains Visual Studio automation object from Running Object Table.
            /// </summary>
            /// <param name="monikerName">The moniker to use as a filter when looking in Running Object Table.</param>
            /// <returns></returns>
            private static DTE GetDteFromRot(string monikerName)
            {
                Contract.Assert(!string.IsNullOrEmpty(monikerName));

                IRunningObjectTable rot;
                IEnumMoniker        monikerEnumerator;
                object dte = null;

                try
                {
                    NativeMethods.GetRunningObjectTable(0, out rot);
                    rot.EnumRunning(out monikerEnumerator);
                    monikerEnumerator.Reset();

                    uint       fetched = 0;
                    IMoniker[] moniker = new IMoniker[1];
                    while (monikerEnumerator.Next(1, moniker, out fetched) == 0)
                    {
                        IBindCtx bindingContext;
                        NativeMethods.CreateBindCtx(0, out bindingContext);

                        string name;
                        moniker[0].GetDisplayName(bindingContext, null, out name);
                        if (name == monikerName)
                        {
                            object returnObject;
                            rot.GetObject(moniker[0], out returnObject);
                            dte = (object)returnObject;
                            break;
                        }
                    }
                }
                catch
                {
                    return(null);
                }

                return((DTE)dte);
            }
            /// <summary>
            /// Obtains Visual Studio automation object from Running Object Table.
            /// </summary>
            /// <param name="monikerName">The moniker to use as a filter when looking in Running Object Table.</param>
            /// <returns></returns>
            private static DTE GetDteFromRot(string monikerName)
            {
                Contract.Assert(!string.IsNullOrEmpty(monikerName));

                IRunningObjectTable rot;
                IEnumMoniker monikerEnumerator;
                object dte = null;
                try
                {
                    NativeMethods.GetRunningObjectTable(0, out rot);
                    rot.EnumRunning(out monikerEnumerator);
                    monikerEnumerator.Reset();

                    uint fetched = 0;
                    IMoniker[] moniker = new IMoniker[1];
                    while (monikerEnumerator.Next(1, moniker, out fetched) == 0)
                    {
                        IBindCtx bindingContext;
                        NativeMethods.CreateBindCtx(0, out bindingContext);

                        string name;
                        moniker[0].GetDisplayName(bindingContext, null, out name);
                        if (name == monikerName)
                        {
                            object returnObject;
                            rot.GetObject(moniker[0], out returnObject);
                            dte = (object)returnObject;
                            break;
                        }
                    }
                }
                catch
                {
                    return null;
                }

                return (DTE)dte;
            }