public VsCustomDebuggerEventHandler(IProfferService profferService, Guid guid, Action <Guid, VsComponentMessage> OnCustomDebugEvent)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            this.profferService  = profferService;
            this.guid            = guid;
            OnCustomDebugEventFn = OnCustomDebugEvent;

            profferService.ProfferService(ref guid, this, out cookie);
        }
Example #2
0
        /// <summary>
        /// Initializes this package.
        /// </summary>
        private void Initialize()
        {
            int hr = NativeMethods.S_OK;

            // If we have any services to proffer, let's do it now.
            if (this.services != null)
            {
                IProfferService ps = (IProfferService)this.GetService(typeof(IProfferService));
                Tracer.Assert(ps != null, "We have services to proffer, but can't get an instance of IProfferService.");
                if (ps != null)
                {
                    foreach (DictionaryEntry entry in this.services)
                    {
                        ProfferedService service = entry.Value as ProfferedService;
                        if (service != null)
                        {
                            Type serviceType = (Type)entry.Key;
                            Guid serviceGuid = serviceType.GUID;
                            uint cookie;
                            hr             = ps.ProfferService(ref serviceGuid, this, out cookie);
                            service.Cookie = cookie;
                            if (NativeMethods.Failed(hr))
                            {
                                string message = this.Context.NativeResources.GetString(ResId.IDS_E_FAILEDTOPROFFERSERVICE, serviceType.FullName);
                                Tracer.Fail(message);
                                throw new COMException(message, hr);
                            }
                        }
                    }
                }
            }

            // Create the Project Factory and register our project types.
            Tracer.WriteLineInformation(classType, "Initialize", "Creating the project factory and registering our project types.");
            IVsRegisterProjectTypes regProjTypes = (IVsRegisterProjectTypes)this.Context.ServiceProvider.GetServiceOrThrow(typeof(SVsRegisterProjectTypes), typeof(IVsRegisterProjectTypes), classType, "Initialize");

            this.projectFactory = this.CreateProjectFactory();
            Guid projectGuid = this.ProjectTypeGuid;

            hr = regProjTypes.RegisterProjectType(ref projectGuid, this.projectFactory, out this.projectCookie);
            if (NativeMethods.Succeeded(hr))
            {
                Tracer.WriteLine(classType, "Initialize", Tracer.Level.Information, "Successfully registered our project types.");
            }
            else
            {
                Tracer.Fail("Failed to register the Wix Project type. HRESULT = 0x{0}", hr.ToString("x"));
            }
        }
Example #3
0
        public BrowserRemotingProxy(System.Windows.Forms.WebBrowser browserControl, string userName, string password)
        {
            this.browserControl = browserControl;
            this.IE = browserControl.ActiveXInstance as InternetExplorer;
            IServiceProvider sp = this.IE as IServiceProvider;

            IOleObject oc = IE as IOleObject;
            oc.SetClientSite(this as IOleClientSite); 
            
            IntPtr objectProffer = IntPtr.Zero;
            uint cookie = 0;

            _userName = userName;
            _password = password;

            sp.QueryService(ref SID_SProfferService, ref IID_IProfferService, out objectProffer);
            theProfferService = Marshal.GetObjectForIUnknown(objectProffer) as IProfferService;
            theProfferService.ProfferService(ref IID_IAuthenticate, this, out cookie);
        }
Example #4
0
        /// <summary>
        /// Add OLE objects necessary for bypassing prompt dialogs
        /// </summary>
        public void InitialiseOLE()
        {
            object     obj = this.ActiveXInstance;
            IOleObject oc  = obj as IOleObject;

            IServiceProvider sp = obj as IServiceProvider;
            IProfferService  theProfferService = null;
            IntPtr           objectProffer     = IntPtr.Zero;
            uint             cookie            = 0;

            sp.QueryService(ref IID_IProfferService, ref IID_IProfferService, out objectProffer);
            theProfferService = Marshal.GetObjectForIUnknown(objectProffer) as IProfferService;
            theProfferService.ProfferService(ref IID_IAuthenticate, this, out cookie);

            // Add Support for bypassing Proxy Authentication dialog
            AuthenticateProxy += delegate(object sender, EnhancedBrowser.AthenticateProxyEventArgs e)
            {
                e.Username = Proxy.Username;
                e.Password = Proxy.Password;
            };
        }
Example #5
0
        /// <summary>
        /// Adds the specified service to the service container, and optionally promotes the
        /// service to parent service containers.
        /// </summary>
        /// <param name="serviceType">The type of service to add.</param>
        /// <param name="serviceInstanceOrCallback">
        /// <para>An instance of the service type to add. This object must implement or inherit
        /// from the type indicated by the <paramref name="serviceType"/> parameter.</para>
        /// <para>- or -</para>
        /// <para>A callback object that is used to create the service. This allows a service
        /// to be declared as available, but delays the creation of the object until the
        /// service is requested.</para>
        /// </param>
        /// <param name="promote">
        /// <see langword="true"/> to promote this request to any parent service containers;
        /// otherwise, <see langword="false"/>.
        /// </param>
        private void AddServiceHelper(Type serviceType, object serviceInstanceOrCallback, bool promote)
        {
            Tracer.Assert(serviceType != null && serviceInstanceOrCallback != null, "Shouldn't have null parameters.");

            // Create the services table if necessary.
            if (this.services == null)
            {
                this.services = new Hashtable();
            }

            bool isCallback          = (serviceInstanceOrCallback is ServiceCreatorCallback);
            Type serviceInstanceType = serviceInstanceOrCallback.GetType();

            if (!isCallback && !serviceInstanceType.IsCOMObject && !serviceType.IsAssignableFrom(serviceInstanceType))
            {
                string message = this.Context.NativeResources.GetString(ResId.IDS_E_INVALIDSERVICEINSTANCE, serviceType.FullName);
                Tracer.Fail(message);
                throw new ArgumentException(message);
            }

            // Disallow the addition of duplicate services.
            if (this.services.ContainsKey(serviceType))
            {
                string message = this.Context.NativeResources.GetString(ResId.IDS_E_DUPLICATESERVICE, serviceType.FullName);
                Tracer.Fail(message);
                throw new InvalidOperationException(message);
            }

            if (promote)
            {
                // If we're promoting, we need to store this guy in a promoted service
                // object because we need to manage additional state.  We attempt
                // to proffer at this time if we have a service provider.  If we don't,
                // we will proffer when we get one.
                ProfferedService service = new ProfferedService();
                service.Instance = serviceInstanceOrCallback;
                if (isCallback)
                {
                    this.services[serviceType] = service;
                }

                if (this.Context.ServiceProvider != null)
                {
                    IProfferService ps = (IProfferService)GetService(typeof(IProfferService));
                    if (ps != null)
                    {
                        uint cookie;
                        Guid serviceGuid = serviceType.GUID;
                        int  hr          = ps.ProfferService(ref serviceGuid, this, out cookie);
                        service.Cookie = cookie;
                        if (NativeMethods.Failed(hr))
                        {
                            string message = this.Context.NativeResources.GetString(ResId.IDS_E_FAILEDTOPROFFERSERVICE, serviceType.FullName);
                            Tracer.Fail(message);
                            throw new COMException(message, hr);
                        }
                    }
                }
            }

            if (!isCallback || (isCallback && !promote))
            {
                this.services[serviceType] = serviceInstanceOrCallback;
            }
        }