private bool Parser_CollectionCompleted(SymbolsForBinary aCollection) { // Check whether the collection contains any item. If it doesn't, ditch it. // Remove empty collections or sort completed ones. bool takeCollection = false; int count = aCollection.Count; if (count > 0) { // Check whether the collection contains at least 2 symbols, and if not // does the one and only symbol just have a length of zero? if (count == 1) { GenericSymbol symbol = aCollection.FirstSymbol; takeCollection = (symbol.Size > 0) || symbol.IsUnknownSymbol; } else { takeCollection = true; } } // If its okay to take the collection, let's sort it and activate if necessary. if (takeCollection) { #if INSPECT_SYMBOL_DATA using (StreamWriter writer = new StreamWriter(@"C:\Temp\OldSymbols\" + Path.GetFileName(aCollection.HostBinaryFileName) + ".symbol")) { aCollection.WriteToStream(writer); } #endif // All the symbol collections - whether they are loaded or idle. iAllSymbols.Add(aCollection); // Then put the collection in the correct container depending on // activation type. if (iActivationType == TActivationType.EImmediate) { aCollection.Sort(); iActivatedSymbols.Add(aCollection); // iRange.UpdateMin(aCollection.AddressRangeStart); iRange.UpdateMax(aCollection.AddressRangeEnd); } else if (iActivationType == TActivationType.EOnDemand) { ThreadPool.QueueUserWorkItem(new WaitCallback(SortCollection), aCollection); iIdleSymbols.Add(aCollection); } } else { //System.Diagnostics.Debug.WriteLine( "Discarded Symbol Collection: " + aCollection.TargetBinary ); //System.Diagnostics.Debug.WriteLine( " " ); } iCurrentBinary = null; return(SymbolFileParser.KCollectionCompletedAndContinueParsing); }
private void SortCollection(object aCollection) { SymbolsForBinary symbols = aCollection as SymbolsForBinary; if (symbols != null) { symbols.Sort(); } }