/// <include file='doc\ShellTypeLoaderService.uex' path='docs/doc[@for="ShellTypeLoaderService.ShellTypeLoaderService"]/*' /> /// <devdoc> /// Creates a new type loader service. /// </devdoc> public ShellTypeLoaderService(IServiceProvider provider) { this.provider = provider; // We need to track solution events. // IVsSolution sol = (IVsSolution)GetService(typeof(IVsSolution)); #if DEBUG if (Switches.TYPELOADER.TraceVerbose) { if (sol == null) { Debug.WriteLine("TypeLoader : No solution found"); } else { Debug.WriteLine("TypeLoader : Attaching solution events"); } } #endif if (sol != null) { solutionEventsCookie = sol.AdviseSolutionEvents(this); } ShellTypeLoader.ClearProjectAssemblyCache(); }
/// <include file='doc\ShellTypeLoaderService.uex' path='docs/doc[@for="ShellTypeLoaderService.IVsSolutionEvents.OnBeforeCloseProject"]/*' /> /// <devdoc> /// </devdoc> int IVsSolutionEvents.OnBeforeCloseProject(IVsHierarchy pHier, int fRemoved) { if (typeLoaders != null) { FlushAllOpenDesigners(); string hierRef = GetHierarchyRef(pHier); ShellTypeLoader typeLoader = (ShellTypeLoader)typeLoaders[hierRef]; if (typeLoader != null) { Debug.WriteLineIf(Switches.TYPELOADER.TraceVerbose, "TypeLoader : Removing typeloader for project " + hierRef); typeLoaders.Remove(hierRef); typeLoader.Dispose(); } } return(NativeMethods.S_OK); }
/// <include file='doc\ShellTypeLoaderService.uex' path='docs/doc[@for="ShellTypeLoaderService.GetTypeLoader"]/*' /> /// <devdoc> /// Retrieves a type loader for the given hierarchy. If there /// is no type loader for this hierarchy it will create one. /// </devdoc> public ITypeResolutionService GetTypeResolutionService(object vsHierarchy) { TypeLoader typeLoader = null; string hierRef; IVsHierarchy hier = vsHierarchy as IVsHierarchy; Debug.Assert(hier != null, "You're not going to get very far without a VS hierarchy"); if (hier != null) { hierRef = GetHierarchyRef(hier); } else { hierRef = defaultProjectRef; } Debug.WriteLineIf(Switches.TYPELOADER.TraceVerbose, "TypeLoader : Loading type loader for hierarchy " + hierRef); if (typeLoaders != null) { // See if the given hierarchy is contained in the current // hash. // typeLoader = (TypeLoader)typeLoaders[hierRef]; } if (typeLoader == null) { Debug.WriteLineIf(Switches.TYPELOADER.TraceVerbose, "TypeLoader : Creating new type loader"); typeLoader = new ShellTypeLoader(this, provider, hier); if (typeLoaders == null) { typeLoaders = new Hashtable(); } typeLoaders[hierRef] = typeLoader; } return(typeLoader); }