public void Dispose() { if (this._locationService != null) { this._locationService.Dispose(); this._locationService = null; } this._filenameMap = null; }
/// <summary> /// Initializes a new <see cref="SourceFileLocationService"/> instance. /// </summary> /// <param name="providerFactories">Ordered set of factories that can supply <see cref="ISourceFileProvider"/> /// instances to perform implementation-specific file location. /// </param> /// <param name="filenameMap">A file name to ID mapping cache to use to keep file names as integer ID's. /// </param> internal SourceFileLocationService(IEnumerable <ISourceFileProviderFactory> providerFactories, FilenameMap filenameMap) { Debug.Assert(providerFactories != null && providerFactories.Count() > 0, "providerFactories are required"); Debug.Assert(filenameMap != null, "filenameMap is required"); this._filenameMap = filenameMap; // Get the provider from each factory, and store our ordered list of providers this._providers = providerFactories.Select(f => f.CreateProvider()).ToArray(); }
/// <summary> /// Initializes a new instance of the <see cref="SharedSourceFiles"/> class. /// </summary> /// <param name="sourceFileLocationService">Service to use to locate source files for types or methods. /// It cannot be null.</param> /// <param name="filenameMap">Cache to map file names to an internal ID and back.</param> /// <param name="sharedFiles">The set of files to consider "shared" in answering requests about types or methods. /// It may be empty but it cannot be null.</param> internal SharedSourceFiles(ISourceFileLocationService sourceFileLocationService, FilenameMap filenameMap, IEnumerable <string> sharedFiles) { System.Diagnostics.Debug.Assert(sourceFileLocationService != null, "sourceFileLocationService cannot be null"); System.Diagnostics.Debug.Assert(filenameMap != null, "filenameMap cannot be null"); System.Diagnostics.Debug.Assert(sharedFiles != null, "sharedFiles cannot be null"); this._sourceFileLocationService = sourceFileLocationService; this._filenameMap = filenameMap; this._anySharedFiles = sharedFiles.Any(); // Don't allocate anything if the list of files is empty if (this._anySharedFiles) { // Get a unique ID for every file declared as shared, and // keep this in a hashset for fast lookup foreach (string sharedFile in sharedFiles) { this._sharedFileIds.Add(this._filenameMap.AddOrGet(sharedFile)); } } }