コード例 #1
0
        /// <include file='doc\StyleBuilderSite.uex' path='docs/doc[@for="StyleBuilderSite.GetBuilder"]/*' />
        /// <devdoc>
        /// </devdoc>
        public object GetBuilder(Type builderType)
        {
            Debug.Assert(builderType != null, "null builder type");

            object builder = null;

            if (site != null)
            {
                try {
                    ILocalRegistry localReg = (ILocalRegistry)QueryService(typeof(ILocalRegistry));
                    Debug.Assert(localReg != null);

                    if (localReg != null)
                    {
                        builder = localReg.CreateInstance(builderType.GUID, null, ref NativeMethods.IID_IUnknown, 1 /*CLSCTX_INPROC_SERVER*/);

                        Debug.Assert(builder != null, "Could not create builder of type: " + builderType.Name);
                        Debug.Assert(builder is NativeMethods.IObjectWithSite, "Builder does not implement IObjectWithSite?");

                        NativeMethods.IObjectWithSite ows = (NativeMethods.IObjectWithSite)builder;
                        ows.SetSite(site);
                        ows = null;
                    }
                }
                catch (Exception e) {
                    Debug.WriteLineIf(StyleBuilder.StyleBuilderSwitch.TraceVerbose, "Exception in StyleBuilderSite::GetBuilder\n\t" + e.ToString());
                    Debug.Fail(e.ToString());

                    builder = null;
                }
            }
            return(builder);
        }
コード例 #2
0
            /// <summary>
            ///     We override VsWindowPane's version of this so we can hand our site
            ///     back to the designer host.  This is necessary so we can get the
            ///     right service routing.
            /// </summary>
            protected override void OnServicesAvailable()
            {
                // get our site
                object site = null;
                Guid   g    = typeof(NativeMethods.IOleServiceProvider).GUID;

                site = this.GetSite(ref g);
                if (site != null)
                {
                    NativeMethods.IObjectWithSite ows = (NativeMethods.IObjectWithSite)host.GetService(typeof(NativeMethods.IObjectWithSite));
                    if (ows != null)
                    {
                        ows.SetSite(site);
                    }
                }
                else
                {
                    Debug.Fail("Failed to get site for DesignerHost");
                }

                // Signal our perf driver that this event is complete.  This signals that the
                // designer has been created and shown.
                //
                DesignerPackage.SignalPerformanceEvent();
            }
コード例 #3
0
        /// <include file='doc\VsService.uex' path='docs/doc[@for="VsService.GetSite"]/*' />
        /// <devdoc>
        ///     Retrieves the requested site interface.  Today we only support
        ///     IOleServiceProvider, which is what must be contained in riid.
        /// </devdoc>
        public object GetSite(ref Guid riid)
        {
            NativeMethods.IObjectWithSite ows = (NativeMethods.IObjectWithSite)serviceProvider.GetService(typeof(NativeMethods.IObjectWithSite));
            if (ows != null)
            {
                return(ows.GetSite(ref riid));
            }
            else
            {
                Marshal.ThrowExceptionForHR(NativeMethods.E_NOINTERFACE);
            }

            return(null);
        }