/// <include file='doc\LanguageService.uex' path='docs/doc[@for="LanguageService.IObjectWithSite.SetSite"]/*' /> /// <internalonly/> public void SetSite(object site) { if (site is IServiceProvider) { this.site = (IServiceProvider)site; } else if (site is IOleServiceProvider) { this.site = new ServiceProvider((IOleServiceProvider)site); } Microsoft.VisualStudio.Shell.Package pkg = (Microsoft.VisualStudio.Shell.Package)this.site.GetService(typeof(Microsoft.VisualStudio.Shell.Package)); this.lcid = pkg.GetProviderLocale(); this.control = new TaskControl(this); }
/// <include file='doc\LanguageService.uex' path='docs/doc[@for="LanguageService.Done"]/*' /> /// <summary> /// Cleanup the sources, uiShell, shell, preferences and imageList objects /// and unregister this language service with VS. /// </summary> public virtual void Dispose() { OnActiveViewChanged(null); this.disposed = true; this.StopThread(); this.lastActiveView = null; if (this.control != null) { this.control.Dispose(); this.control = null; } if (this.sources != null) { lock (this.sources) { foreach (Source s in this.sources) { s.Dispose(); } this.sources.Clear(); } this.sources = null; } if (this.colorizers != null) { foreach (Colorizer c in this.colorizers) { c.Dispose(); } this.colorizers.Clear(); this.colorizers = null; } if (this.codeWindowManagers != null) { foreach (CodeWindowManager m in this.codeWindowManagers) { m.Close(); } this.codeWindowManagers.Clear(); this.codeWindowManagers = null; } if (this.preferences != null) { this.preferences.Dispose(); this.preferences = null; } if (this.debugger != null && this.cookie != 0) { NativeMethods.ThrowOnFailure(this.debugger.UnadviseDebuggerEvents(this.cookie)); this.cookie = 0; this.debugger = null; } if (this.task != null) this.task.Dispose(); this.task = null; this.site = null; }