public HmeServer(string name, Uri applicationPrefix, HmeServerOptions options, IHmeApplicationPump pump, IServiceProvider parentProvider) { _name = name; ApplicationPrefix = applicationPrefix; _pump = pump; iconUri = applicationPrefix.AbsolutePath + "icon.png"; _advertise = (options & HmeServerOptions.AdvertiseOnLocalNetwork) == HmeServerOptions.AdvertiseOnLocalNetwork; _serviceContainer = new System.ComponentModel.Design.ServiceContainer(parentProvider); _serviceContainer.AddService(typeof(IHttpApplicationHostPool), new HttpApplicationHostPool()); _usePort = 7688; if (applicationPrefix.IsAbsoluteUri) { _usePort = (short)applicationPrefix.Port; } // everything important to initialization must happen before here since the events can // be raised immediately. lock (_portServers) { HmePortServer portServer; if (!_portServers.TryGetValue(_usePort, out portServer)) { portServer = new HmePortServer(_usePort); _portServers.Add(_usePort, portServer); } portServer.ConnectionReceived += HttpServer_HttpConnectionReceived; } }
/// <summary> /// Initializes the package. /// </summary> /// <remarks>This method is called right after the package is sited, so this is the place to initialize /// code that relies on services provided by Visual Studio.</remarks> protected override void Initialize() { base.Initialize(); if (!this.SetupMode) { System.ComponentModel.Design.IServiceContainer sc = (System.ComponentModel.Design.IServiceContainer) this; sc.AddService(typeof(IVsPackage), this, false); // Ensure that the IDE enviroment is available. EnvDTE.DTE dte = (EnvDTE.DTE) this.GetService(typeof(EnvDTE.DTE)); if (dte == null) { throw new InvalidOperationException(Strings.CouldNotGetVSEnvironment); } this.Core.Initialize(null, true); this.Helper.Initialize(); // Ensuring that the form is created on the UI thread. if (InvisibleForm.Instance == null) { throw new InvalidOperationException(Strings.NoInvisbileForm); } // Set up the menu items. this.AddMenuItems(); } }